I’ve been working on a case where customer accidently deleted a bunch of timer jobs. He came to us with a question on how to restore the timer jobs back. We found a way to restore the timer jobs but just a few of them. So if the timer jobs are out of the box (OOB) jobs we can restore them in this manner. If there are other timer jobs you’ll have to just re-deploy the timer job solution again.
Farm Level Timer Jobs
From code I see that SPTimerService.EnsureDefaultJobs should restore the following farm level timer jobs…
job-config-refresh job-ceip-datacollection job-delete-job-history job-password-management job-app-installation SPAppStatisticsProviderJobDefinition job-autohosted-appinstance-counter job-admin-product-version job-timer-recycle job-timer-locks job-spapp-statequery job-internalspapp-statequery
Web Application Level Timer Jobs
There’s another one SPWebApplication.EnsureDefaultJobs which restores following web application level timer jobs.
job-immediate-alerts job-dead-site-delete job-diskquota-warning job-change-log-expiration job-recycle-bin-cleanup job-workflow-autoclean job-workflow-failover job-workflow job-site-deletion job-audit-log-trimming job-solution-resource-usage-log job-solution-resource-usage-update job-solution-daily-resource-usage job-upgrade-workitems job-filefragments-cleanup job-storage-metrics-processing job-create-upgrade-eval-sites job-delete-upgrade-eval-sites job-upgrade-sites
So the question is how to execute these functions via PowerShell…
# Ensures the default farm level timer job definitions exist Add-PSSnapin Microsoft.Sharepoint.Powershell $farm = Get-SPFarm $farm.TimerService.EnsureDefaultJobs(); #Ensures the default timer job definitions exist for the specified web application $webapp = Get-SPWebApplication http://webapp/ $webapp.EnsureDefaultJobs();
Thanks to my colleague Stephen Woodard and Trevor Barkhouse for pointing me to this public function.
As always please make sure you test this out well before implementing this in production.