Check IIS Health (Services, Site, AppPool Statuses)

This is a simple script that will query the Windows Services for the status of the required IIS services (IISADMIN, WAS, W3SVC) and also output the status of your IIS sites and apppools. Although it is a PowerShell script, it takes advantage of the built in c:\windows\system32\inetsrv\appcmd.exe command-line feature – if you have not worked with this CLI tool before, I do encourage you to interact with it as it is a great tool for administering IIS through the CLI rather than inetmgr.

Write-Host "`nScript executed by $env:username for $(Get-Date -f ""MM-dd-yyyy hh:mm:ss"")"
Write-Host "`nWeb Health Check for $(hostname)"
Write-Host "-------------------------------------`n"

Write-Host "IIS Services"
Write-Host "-------------"
Write-Host "IIS Admin Service ( IISADMIN ) - "$(Get-Service -Name "IISADMIN" | Select -ExpandProperty Status)
Write-Host "Windows Process Activation Service ( WAS ) - "$(Get-Service -Name "WAS" | Select -ExpandProperty Status)
Write-Host "World Wide Web Publishing Service ( W3SVC ) - "$(Get-Service -Name "W3SVC" | Select -ExpandProperty Status)

"`n"

$siteList = c:\windows\system32\inetsrv\appcmd.exe list sites
$appList = c:\windows\system32\inetsrv\appcmd.exe list apppools

Write-Host "Site Status"
Write-Host "--------------"
foreach ($site in $siteList)
{
	Write-Host $site
}

"`n"

Write-Host "Apppool Status"
Write-Host "--------------"
foreach ($app in $appList)
{
	Write-Host $app
}
"`n"




Here is a sample run:

Script executed by knguyen for 07-25-2018 10:03:23

Web Health Check for (Server name will be printed here)
————————————-

IIS Services
————-
IIS Admin Service ( IISADMIN ) – Stopped
Windows Process Activation Service ( WAS ) – Running
World Wide Web Publishing Service ( W3SVC ) – Stopped

Site Status
————–
SITE “Default Web Site” (id:1,bindings:http/*:80:,net.tcp/808:*,net.pipe/*,net.msmq/localhost,msmq.formatname/localhost,state:Unknown)

Apppool Status
————–
APPPOOL “DefaultAppPool” (MgdVersion:v4.0,MgdMode:Integrated,state:Started)
APPPOOL “ASP.NET v4.0” (MgdVersion:v4.0,MgdMode:Integrated,state:Started)
APPPOOL “ASP.NET v4.0 Classic” (MgdVersion:v4.0,MgdMode:Classic,state:Started)

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments