IISRESET all servers in farm using PowerShell
--- snip ---
if((Get-PSSnapin -Name Microsoft.Sharepoint.PowerShell -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin Microsoft.Sharepoint.PowerShell } function Reset-Services{ # Connect to the farm $Farm = Get-SPFarm foreach ($Server in $Farm.Servers) { $ServerName = $Server.Name $ServerRole = $Server.Role if ($Server.Role -ne "Invalid") { Write-Host "Restarting IIS Services on $ServerName." IISReset $ServerName IISReset $ServerName /Status } } } Reset-Services-- snip --if((Get-PSSnapin -Name Microsoft.Sharepoint.PowerShell -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin Microsoft.Sharepoint.PowerShell } function Reset-Services{ # Connect to the farm $Farm = Get-SPFarm foreach ($Server in $Farm.Servers) { $ServerName = $Server.Name $ServerRole = $Server.Role if ($Server.Role -ne "Invalid") { Write-Host "Restarting IIS Services on $ServerName." IISReset $ServerName IISReset $ServerName /Status Write-Host "Restarting Timer Job on $ServerName." $Service = Get-WmiObject -Computer $ServerName Win32_Service -Filter "Name='SPTimerV4'" if ($Service -ne $nll) { $Service.InvokeMethod('StopService',$null) Start-Sleep -s 7 $service.InvokeMethod('StartService',$null) Start-Sleep -s 7 Write-Host "Timer Job successfully restarted on $ServerName." } } } } Reset-Services
No comments:
Post a Comment