Restart IIS (IISRESET) on All Servers in the SharePoint Farm using PowerShell
Doing IISReset on a Server Farm with Multiple SharePoint servers is a painful process. If you are experiencing problems with IIS on your SharePoint servers, you may need to restart it. This blog post will show you how to restart IIS on all servers in a SharePoint farm.
PowerShell Script to Restart IIS on All SharePoint Servers:
If you ever need to restart IIS on all servers in the SharePoint farm, Here is a nifty solution to do IISRESET on all SharePoint Servers using PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
#Get All SharePoint Servers - Except DB and SMTP Servers
$Servers = Get-SPServer | Where {$_.Role -ne "Invalid" }
#Iterate through the list and restart one by one.
foreach ($server in $servers)
{
Write-Host "Restarting IIS on server: $($Server.Name)"
IISRESET $Server.Address
#Optional: Get the Status
Write-Host "IIS status for server $($server):"
IISRESET $server.Address /status
}
Write-host "IIS Restarted on All Servers of the Farm!" -f Green
Make sure you have “Local Administrator” Permission on all servers you want to reset IIS.