-
Notifications
You must be signed in to change notification settings - Fork 107
SPTimerJobState
Yorick Kuijs edited this page Sep 14, 2018
·
19 revisions
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
TypeName | Key | String | The type name of the timer job (not the display name) | |
WebAppUrl | Key | String | The URL of the web application that the timer job belongs to. Use the value 'N/A' if no web application is applicable | |
Enabled | Write | Boolean | Should the timer job be enabled or not | |
Schedule | Write | String | The schedule for the timer job to execute on | |
InstallAccount | Write | PSCredential | POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5 |
Type: Distributed
This resource is used to configure a timer job and make sure it is in a specific state. The resource can be used to enable or disabled the job and configure the schedule of the job.
The schedule parameter has to be written in the SPSchedule format (https://technet.microsoft.com/en-us/library/ff607916.aspx).
Examples are:
- Every 5 minutes between 0 and 59
- Hourly between 0 and 59
- Daily at 15:00:00
- Weekly between Fri 22:00:00 and Sun 06:00:00
- Monthly at 15 15:00:00
- Yearly at Jan 1 15:00:00
NOTE: Make sure you use the typename timer job name, not the display name! Use "Get-SPTimerJob | Where-Object { $_.Title -eq "<Display Name>" } | Select typename" to find the typename for each Timer Job.
NOTE2: You cannot use SPTimerJobState to change the Health Analyzer jobs, because these are configured to specific times by default.
This example show how to disable the dead site delete job in the local farm.
Configuration Example
{
param(
[Parameter(Mandatory = $true)]
[PSCredential]
$SetupAccount
)
Import-DscResource -ModuleName SharePointDsc
node localhost {
SPTimerJobState DisableTimerJob_AppServerJob
{
TypeName = "Microsoft.Office.Server.Administration.ApplicationServerJob"
WebAppUrl = "http://sites.sharepoint.contoso.com"
Enabled = $false
Schedule ="weekly at sat 5:00"
PsDscRunAsCredential = $SetupAccount
}
}
}
- Home
- Getting Started
- Pre-requisites
- Installing the module
- Exporting SharePoint Configuration
- Creating Configuration Files
- Pre-created Examples
- Creating an Azure development environment
- Understanding Resources & Syntax
- Remote PowerShell Authentication
- Contributing to SharePointDsc
- Other useful modules for SharePoint DSC configurations