Managing Sharepoint Timer Jobs using PowerShell

#function to enable the timer job if its disabled

function EnableTimerJobIfDisabled ( [String]$TimerJobName)

{

[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

if(CheckTimerJobStatus)

{

Get-SPTimerJob $TimerJobName

Enable-SPTimerjob -Identity $TimerJobName

write-host “Enabled $TimerJobName”

}

}

 
 

 #### Enable Timer Job ####

#Enable the timer job if it is disabled

#EnableTimerJobIfDisabled -TimerJobName “timerjobname”

 

 

 

#Disable the Timer Job if its Enabled

function DisableTimerJobIfEnabled ( [String]$TimerJobName)

{

[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

Get-SPTimerJob $TimerJobName | Disable-SPTimerJob

write-host “Disabled $TimerJobName”

}

 
 

 #### Disable Timer Job ####

#Disbale the timer job if it is enabled

#DisableTimerJobIfEnabled -TimerJobName “timerjobname”

 

 

 

#function to check for the timer job status

function CheckTimerJobStatus ( [String]$TimerJobName)

{

[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

$isDisabled=Get-SPTimerJob $TimerJobName | select IsDisabled

return $isDisabled

}

 
 

 #use this to check the timer job status

#CheckTimerJobStatus -TimerJobName “nameofthetimerjob”

 
 

 
 

 
 

#### Check Timer Job Status ####

#use this to check the timer job status

#CheckTimerJobStatus -TimerJobName “timerjobname”

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami