Share via


SharePoint 2010: Restarting the Timer Service on all Servers in a SharePoint Farm using PowerShell

The following PowerShell script can be used to restart the SharePoint Timer service (SPTimerV4) on all the servers in a SharePoint Farm.

[array]$servers= Get-SPServer | ? {$_.Role -eq "Application"}            
$farm = Get-SPFarm            
foreach ($server in $servers)            
{            
    Write-Host "Restarting Timer Job on $server"                                      
    $Service = Get-WmiObject -Computer $server.name Win32_Service -Filter "Name='SPTimerV4'"                        
    if ($Service -ne $null)                         
    {                             
        $Service.InvokeMethod('StopService',$null)            
        Start-Sleep -s 7            
        $service.InvokeMethod('StartService',$null)                             
        Start-Sleep -s 7            
        Write-Host "Timer Job successfully restarted on $server"                        
    }             
    else            
    {            
        write-host -ForegroundColor Yellow "Could not find SharePoint 2010 Timer Service on $server"            
    }            
}

Other languages

This article is also available in the following languages :