Friday, January 27, 2012

PowerShell: IISRESET Multiple Web Servers

The following script will perform an IISRESET.  Use this to reset Internet Information Services on Windows 2008 Servers with the Web Server role enabled.  It is best to run it on one of the servers, and not from your desktop (unless your account has Administrator or Power User rights to the server).

##########################################################################
###                                                                    ###
###     Array contains the server names.  Change these if needed.      ###
###                                                                    ###
##########################################################################
FILENAME = "MASS-IISRESET.PS1"
[Array]$servers = "Web_Server_1","Web_Server_2"
foreach ($server in $servers)
{
 Write-Host "Restarting IIS on $server..."
 IISRESET $server /noforce
 Write-Host "$server IIS Status: "
 IISRESET $server /status
}
Write-Host IIS has been restarted.  Sites will be up in a moment.

No comments:

Post a Comment