How to Delete a Timer Job in SharePoint using PowerShell?
But wait! why do we delete a Timer Job in SharePoint? Well, because:
- Your custom timer job may be in stuck state
- You may have orphaned Timer jobs (Timer job without “Server” from Timer job status page in Central Admin)
- Your custom timer job may have created more than one instances (duplicate timer job)
In my case, a custom timer job deployed in our SharePoint 2013 environment had a bug and left two instances of the same timer job. so we wanted to delete that.
Delete a Custom Timer Job in SharePoint
There is no Central Admin UI to delete timer jobs in SharePoint. So, lets seek help from PowerShell to delete a timer job in SharePoint.
How to Delete a Timer Job in SharePoint using PowerShell?
- Step 1: Obtain the GUID of your target timer job to delete
Get-SPTimerJob | where { $_.name -like "YOUR-Timer-Job-Name" } | Format-Table -autosize -Property LastRunTime,id,name,DisplayName,Status
- Step 2: Get the timer job and delete
Once you obtained the GUID of your timer job to delete, run this PowerShell cmdlet:$Timerjob = Get-SPTimerJob -id <Timer Job's GUID> $Timerjob.Delete()
This PowerShell script removes the given SharePoint timer job!
Lesson Learned: Developers – Make sure your Feature deactivation module contains code to delete your custom timer job in SharePoint.
How to find the GUID of the timer job?
E.g. use: Get-SPTimerJob | where { $_.Title -like “Audit Log Trimming” } | Select ID, WebApplication, Service