[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"
}
}