Restart IIS (IISRESET) on All Servers in the SharePoint Farm using PowerShell

Doing IISReset on Server Farm with Multiple SharePoint servers is a painful process. 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:

PowerShell Script to Restart IIS on All SharePoint Servers:

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.

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply