Perform an IIS Reset on all your SP Servers via PowerShell

This script will list all your SP Servers and restarts IIS on all of them.

 

add-pssnapin microsoft.sharepoint.powershell
$spserver = get-spserver | ?{$_.role -eq "Application"}
foreach ($server in $spserver)
{
   write-host "Performing IIS Reset on Server:"$server.name
   iisreset $server.Name
}

Comments

  • Anonymous
    February 26, 2015
    Perfect.. Thank you so much for sharing... !!
  • Anonymous
    September 05, 2015
    awesome trick
    thanks
  • Anonymous
    September 05, 2015
    Thanks Thomas for your effort.
  • Anonymous
    May 17, 2016
    If you haven't set up RPC this won't work, however the SP install user is set up for remote PowerShell commands, so this will work as that user with no additional configuration:$spserver = get-spserver | ?{$.role -eq "Application"}$spserver | % {Invoke-Command -ComputerName $.Address {iisreset}}