다음을 통해 공유


Run SP Timer Job in PowerShell with its Name

I was trying to find the most easiest way to run a timer job that my dev team always asked me to. I did not want to go to the UI and do it. Cause powershell is quick and also running script seems cool. So I created the below powershell script to run any job whose name you know. 

Note- Incase you do not see the Job status/ Job last run time that means that the name you have given in not correct. So verify it cause it can be easily confused with DisplayName, title... yes these are three properties if you look up the list of properties for Get-sptimerjob. So confirm the correct name.

Code

Add-PSSnapin Microsoft.Sharepoint.powershell $identity = Read-Host "Type the name of the job"  get-sptimerjob -Identity $identity | Start-SPTimerJob Write-Host -BackgroundColor White -ForegroundColor Black "NOTE -If no update after Job status; The Name is incorrect" Start-Sleep -Seconds 5 write-host "`n" Write-Host -ForegroundColor black -BackgroundColor white "Job Status" Start-Sleep -Seconds 3 Get-SPTimerJob -Identity $identity |Format-List -Property DisplayName, LastRunTime

Please paste the above code into a notepad and save it with the desired name with extension ".ps1".

Happy scripting
Anil