Monday, February 11, 2013

PowerShell : Manually kick off timer job

Needed to execute a timer job using PowerShell rather than waiting for a schedule to pick it up. Here is the code. (Remember to assign variables as needed).
# Kick off the timer job
Write-Host "Starting to execute timer job.."$TimerJob1Name -NoNewline -ForegroundColor Cyan
$TimerJob = $WebApp.JobDefinitions | Where-Object { $_.Name -eq $TimerJob1Name}
Start-SPTimerJob $TimerJob
Write-Host "Done." -ForegroundColor Green

No comments:

Post a Comment