Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use PowerShell to Monitor IIS Websites and Application Pools
$Servers = ''
Invoke-Command -ComputerName $Servers {
Import-Module -Name WebAdministration
$Websites = Get-Website
foreach ($Website in $Websites)
{
$AppPool = $Website.applicationPool
If ((Get-WebAppPoolState -Name $AppPool).Value -eq 'Stopped') {Start-WebAppPool -Name $AppPool}
$SiteState = $Website.State
If ($SiteState -eq 'Stopped') {Start-Website -Name $Website.Name}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.