Managing SharePoint 2013 with PowerShell: Working with Timer Jobs

Posted on November 6, 2013 by Michael Simmons in SharePoint with 0 Comments

Timer jobs are automated tasks working behind the scenes of your SharePoint farm. They fill many different roles, from performing health analysis to synchronizing workflow items.  The timer service is constantly working to keep things in sync and humming along smoothly. Like most things in SharePoint 2013, timer jobs can be looked at and administered through Central Administration but to really control of them requires PowerShell. This article shows you how to view, modify, and run timer jobs in SharePoint 2013 using PowerShell.

(Editor’s note: Be sure to check out our previous article, “Managing SharePoint 2013 with PowerShell: Creating a Search Application.”)

To work with PowerShell for your SharePoint farm, you’ll need to remote to your SharePoint 2013 server and start a PowerShell session.  Once started, you can load the SharePoint Administration module.

Add-PSSnapin Microsoft.SharePoint.PowerShell

The rest of the commands in this article rely on this module.

View SharePoint 2013 Timer Jobs with PowerShell

You can get a window into the Timer Jobs: what timer jobs are there, what schedule they run on, and even the status of them at their last runtime using Get-SPTimerJob. However, it can be a little like trying to drink from a firehose. A default SharePoint 2013 installation has about 200 timer jobs running. Thankfully, we can use several methods for trimming the results.

Filter Timer Jobs by Name, GUID, or Instance Object

Using the –Identity parameter allows you to specify a timer job by name or GUID. Behind the scenes, this also allows you to timer jobs saved in variables directly to the Get-SPTimerJob object.

Get-SPTimerJob –Identity “Name”

If you are going to filter by name, you’ll need to be specific. No wildcards are allowed. If you need to filter by names with wildcards, pipe the results to the Where-Object.

Get-SPTimerJob | Where-Object {$_.Name –like “*health*”}


Filter Timer Jobs by Web Application

Use the –WebApplication parameter to filter the timer jobs to those that run on a specific web application. Just like filtering by identity, you can’t use wildcards.

Get-SPTimerJob –WebApplication “http://hr.intranet.local”

Start a Timer Job with PowerShell

Timer jobs start on a schedule, but if you need one to begin right away, you can easily start it with the Start-SPTimerJob cmdlet. While you can specify an identity for the Start-SPTimerJob in the same way as you can with the Get-SPTimerJob, you’ll usually pipe the timer jobs into Start-SPTimerJob.

Get-SPTimerJob –WebApplication “http://hr.intranet.local” | Where-Object {$_.Name –like *health*”} | Start-SPTimerJob

Disable a Timer Job with PowerShell

If you want to prohibit a timer job from running, but not modify its schedule, then you have the option to disable the timer job. Once disabled, a timer job cannot be started.

You can use the Disable-SPTimerJob cmdlet to keep the timer jobs from running. Similar to the Start-SPTimerJob, Disable-SPTimerJob accepts the –Identity parameter so you can identify the timer job by its name or GUID. You can also pipe in the objects from a Get-SPTimerJob.

Get-SPTimerJob –WebApplication “http://staff.intranet.local” | Where-Object {$ –like “*health*” } | Disable-SPTimerJob

Enable a Timer Job with PowerShell

Of course, after disabling a timer job you’ll probably want to enable it again at some point. This is done through the Enable-SPTimerJob cmdlet.

By now, you’re probably expecting that you can use the Identity parameter to specify a Timer Job by name or GUID, and you’re right. You can also pipe in the results from a Get-SPTimerJob cmdlet.

Get-SPTimerJob | Where-Object {$ –like “*health*”} | Enable-SPTimerJob

Why would you want to use the Get-SPTimerJob cmdlet if all of the other TimerJob cmdlets accept the name and GUID in them?

Remember that the Get-SPTimerJob accepts more parameters than just identity. You can filter the list by web application, and that is the only TimerJob cmdlet that provides that filter. Another reason to use Get-SPTimerJob is that it is an easy way to save all of the timer jobs that you want to work with into a variable that can be referenced later.


Change the Schedule of a Timer Job in SharePoint 2013

Schedules for the individual timer jobs can be set through the Set-SPTimerJob cmdlet. You can specify a time to run by specifying an interval of at least one minute, or as infrequently as once a year, and a range of times or dates to run on.

Get-SPTimerJob “ExpirationProcessing” | Set-SPTimerJob –Schedule “weekly at sun 02:00:00”

Because there is such a variety in the flexibility of the schedules, there are several ways to write them. Here are some tips to make your schedules appear the way you want them.

  • Use three-letter abbreviations for the days of the week (Mon, Tue, Wed, Thu, Fri, Sat, Sun).
  • Use the three-letter abbreviations for the months (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec).
  • Capitalization doesn’t matter.
  • Time is in the format: hh:mm:ss.
  • Dates are in the format of month abbreviation followed by date. “Jun 13”
  • Schedules that use a time range start the interval at a random time between the start and end to avoid resource hogging.

Syntax for the Schedules

You can specify your schedules in a nearly conversational format, with the schedule appearing in a (mostly) natural tone.

The interval

When you’re creating your schedules, you will use a slightly different formatting based on the interval of the timer job. The available intervals are “by the minute,” “hourly,” “daily,” “weekly,” “monthly,” and “yearly”

The start time

The start time can either be at a specific time or between two times. If you use “between,” then a time will be chosen at random for the beginning of the first timer job and the timer job will proceed at the interval time for subsequent starts. This randomization of start times helps to keep everything from firing off at the same time.

Here are the examples for the syntax of the different styles of scheduling intervals.

By the minute

Example:  Every three minutes between 0 and 20

Notes: This would start at a random time between the top of the hour and twenty past, then occurs every three minutes afterwards.


Example: Hourly at 30

Notes: Begins at 30 minutes past the next hour, then continues every hour.


Example: Daily between 6:00:00 and 8:00:00

Notes: A random time is chosen between 6 and 8 am to process this job. The job will process at (roughly) the same time every day.


Example: Daily between 6:00:00 and 8:00:00

Notes: A random time is chosen between 6 and 8 am to process this job. The job will process at (roughly) the same time every day.


Example: Monthly at 1


Example: Yearly between Jan 1 00:00:01 and Jan 05:00:00

You can see that the there is a lot of flexibility in the scheduling of the timer jobs, and even batching the scheduling of several jobs through the use of the “between” scheduling allows you to script the scheduling. By using a single string like “every five minutes between 0 and 59,” you’ll still get a nice spreading of your timer jobs running throughout the hour instead of having them all trying to start at the same time.

Now Go Forth and Conquer Your Timer Jobs

You now know everything you need to know to gather your timer job maintenance tasks into manageable chunks and script yourself silly with PowerShell. Are you using PowerShell to its full advantage in your SharePoint administration?  Let me know how it’s going in the comments below, or connect with me on Twitter or Facebook.


Tagged with , ,