Created
December 29, 2018 10:11
-
-
Save AshFlaw/73ab7d4a435bd023f857e1e685b7e12b to your computer and use it in GitHub Desktop.
Use PowerShell to Monitor IIS Websites and Application Pools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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