How restore SP default TimerJobs via PowerShell

How restore SP default TimerJobs via PowerShell


How to restore SP Default TimerJobs via Powershell:



Scenario: 

You manage SharePoint 2013 and noticed that the TimerJobHistory table is huge (which is putting a strain on the available storage). On further investigation you notice the job-delete-job-history task has not run for over 10 months. 


The solution to this scenario would be to restore all default TimerJobs. Timer job “job-delete-job-history” is configured by default when a new farm is created. It can be restored by running the command below:


$farm = Get-SPFarm

$farm.TimerService.EnsureDefaultJobs()


Then run the command below for specific web application:


$w = Get-SPWebApplication http://sp

$w.EnsureDefaultJobs()


That should resolve the issue you are experiencing.