Hi,
Recently many site admins requested me to provide an easy way to delete a timer job. A timer job can always be deleted via a non documented STSADM command as
Recently many site admins requested me to provide 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 production environment. Hence to resolve this issue I created a powershell script that takes only one input as the guid of the timer job and deletes it. Here is the script :
param([string]$jobid)
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
function RahulDeleteTimerJob($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"
}
RahulDeleteTimerJob $jobid
I hope this will help you out.
Thanks,
Rahul Rashu
No comments:
Post a Comment