Run SharePoint 2010 Timer Jobs On-Demand with PowerShell

We may have to run SharePoint timer jobs on-demand in some situations. Say for e.g. To update Rating values, I had to run the timer jobs: User Profile Service Application – Social Rating Synchronization Job and User Profile Service Application – Social Data Maintenance Job. Read more at SharePoint 2010 Rating Feature Configuration

How to run a timer job manually in SharePoint?

So, To run a SharePoint 2010 timer Jobs on-demand, we used to navigate to Central Administration >> Monitoring >> Timer Jobs >> Review Job Definition >> Pick the timer jobs we want to run >> Click on “Run Now”, BTW SharePoint 2007 doesn’t offer a way to run timer job manually!

how to run timer job manually in sharepoint

This will run timer job immediately in SharePoint 2010.

SharePoint 2013 run timer job from PowerShell:

We can run timer job from code.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Display name of the Timer Job to Run on-demand
$TimerJobName = "User Profile SA - Social Rating Synchronization Job" 

#Get the Timer Job 
$TimerJob = Get-SPTimerJob | where { $_.DisplayName -match $TimerJobName}

#start the timer job
Start-SPTimerJob $TimerJob

#Or use this One-liner:
#Get-SPTimerJob | where { $_.DisplayName -match "User Profile SA - Social Rating Synchronization Job"} | Start-SPTimerJob

I’ve used display name here, which various based on your installation. You can also use “Name” attribute, like:

$TimerJob = Get-SPTimerJob | where { $_.Name -eq "User Profile Service_SocialRatingSyncJob" } 

Run SharePoint timer job programmatically with PowerShell:

In some other cases, you may have a timer job associated with multiple web applications and want to run a particular web app’s timer job:

#Display name of the Timer Job to Run on-demand
$TimerJobName = "Workflow Auto Cleanup" 

#Get the Web Application
$WebApp = Get-SPWebApplication "http://sharepoint.crescent.com"

#Get the Timer Job associated with the given web application
$TimerJob = Get-SPTimerJob | where { $_.DisplayName -match $TimerJobName} | where {$_.Parent -eq $WebApp }

#start the timer job
Start-SPTimerJob $TimerJob

How to run SharePoint 2007 Timer job on-demand?

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")  
[void][reflection.assembly]::LoadwithPartialName("Microsoft.Office.Server")

Function global:Get-SPWebApplication($WebAppURL)
{
 return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)
}
#Get the web application
$WebApp = Get-SPWebApplication "https://sharepoint.crescent.com"

foreach ($TimerJob in $WebApp.JobDefinitions)
{
  if($TimerJob.Title -eq "Profile Synchronization")
  {
     $TimerJob.Execute([guid]::Empty)
  }
}

Please note, This doesn’t update “LastRun” time!

Using STSADM  to run timer jobs on-demand:
You can use “STSADM” to change the timer job schedule and make them run immediately. E.g. Lets get the “Recycle bin cleanup” timer job schedule.

stsadm -o getproperty -propertyname “job-recycle-bin-cleanup” -url “http://your-sharepoint-webpapp”

This should return the output as:
<Property Exist=”Yes” Value=”daily between 22:00:00 and 06:00:00″ />

We can change the schedule
stsadm -o setproperty -propertyname “job-recycle-bin-cleanup” -url “http://your-sharepoint-webpapp” -propertyvalue “Every 1 minutes between 0 and 59”

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

3 thoughts on “Run SharePoint 2010 Timer Jobs On-Demand with PowerShell

  • September 12, 2013 at 4:02 PM

    Thanks a lot

    Reply
  • August 6, 2013 at 12:37 PM

    How do I run “User Profile Service Application – Social Data Maintenance Job” Timer Job?

    Reply
    • August 6, 2013 at 12:40 PM

      To get User Profile Service Application – Social Data Maintenance Job, use:

      $TimerJob = Get-SPTimerJob | where { $_.Name -eq “User Profile Service_SocialDataMaintenanceJob” }

      Reply

Leave a Reply