magritton
11/15/2016 - 10:39 PM

This restarts all of the timer services on all of the servers in the farm.

This restarts all of the timer services on all of the servers in the farm.

$farm = Get-SPFarm
$farm.TimerService.Instances | foreach {$_.Stop();$_.Start();} 

[array]$servers= Get-SPServer | ? {$_.Role -eq "Application"} 
foreach ($server in $servers) 
{ 
    Write-Host "Restarting Timer Service on $server" 
    $Service = Get-WmiObject -Computer $server.name Win32_Service -Filter "Name='SPTimerV4'" 

    if ($Service -ne $null) 
    { 
        $Service.InvokeMethod('StopService',$null)
        Start-Sleep -s 8

        $service.InvokeMethod('StartService',$null) 
        Start-Sleep -s 5 

        Write-Host -ForegroundColor Green "Timer Job successfully restarted on $server" 

    } 
    else 
    {  
        Write-Host -ForegroundColor Red "Could not find SharePoint Timer Service on $server" 

    } 

}