Quantcast
Channel: SharePoint Diary
Viewing all articles
Browse latest Browse all 1058

Run SharePoint 2010 Timer Jobs On-Demand with PowerShell

$
0
0
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 timer job manually in SharePoint 2010
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 way to run timer job manually!
how to run timer job manually in sharepoint 2010
This will run timer job immediately in SharePoint 2010.

SharePoint 2010 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 useddisplay 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 2010 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

Viewing all articles
Browse latest Browse all 1058

Trending Articles