Sharepoint: How to delete a timer job using PowerShell
Many site admins need an easy way to delete a timer job.
A timer job can always be deleted via a non-documented STSADM command as
STSADM -o deleteconfigurationobject -id guid.
However, this command is not recommended for the production environment. Hence to resolve this issue, this PowerShell script takes only one input as the guid of the timer job and deletes it.
Script
param([string]$jobid)
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
function DeleteTimerJob($jobid) {
write-host "This script will delete a timer job"
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$services = $farm.Services
foreach($service in $services)
{
$jobdefs = $service.JobDefinitions
foreach($job in $jobdefs)
{
if($job.Id.ToString() -eq $jobid)
{
$job.Delete()
}
}
}
write-host "The job is deleted"
}
DeleteTimerJob $jobid
I hope this will help you out.