Library / Windows Server and AD

SERVER-018 · Script

Check IIS Health

Checks IIS websites, application pools and HTTPS certificates on this server, and can start anything that stopped.

Version 1.0.0Language PowerShellUpdated November 2026

What it does

Runs on the IIS server itself and reports:

  • Websites: running or stopped, with their bindings

Application pools running or stopped HTTPS certificates expired or expiring within -CertWarnDays (default 30)

  • Web addresses: optional: each address in -Url is requested and the response code recorded

Report mode (default) changes nothing. Fix mode starts stopped application pools first, then stopped websites. Anything listed in -IgnoreName is reported but never counted or started.

Requirements

Windows PowerShell 5.1 and the WebAdministration module (IIS Management Scripts and Tools). Run as SYSTEM or a local administrator.

How to run it

  • Run as: a service account with the directory rights the script lists, or SYSTEM on a domain controller or the server being checked
  • Run from: a domain-joined management server or admin workstation with the RSAT tools, as a scheduled task or from your management tool
  • Script type: PowerShell 5.1, 64-bit
  • User interaction: none; the script never prompts
  • Timeout: 30 minutes for large directories or many servers

Settings

NameWhat it doesOptionsDefault
ModeReport (default) or Fix.Report, FixReport
UrlWeb addresses to request, for example https://intranet.school.local/. Redirects are followed; a final response from 200 to 399 passes.(none)
IgnoreNameSite or app pool names that are stopped on purpose.(none)
CertWarnDaysFlag HTTPS certificates that expire within this many days. Default: 30.30
TimeoutSecondsHow long to wait for each web address. Default: 15.15

Exit codes

  • 0 = Everything running and passing
  • 1 = Something is stopped, failing, or has a certificate problem
  • 2 = Script error (see log)

Testing steps

  1. Run it first with the mode set to Report on one test OU, test account or test server. Nothing is changed in that mode.
  2. Read the log and confirm the planned changes are what you expect.
  3. Run your chosen settings on the same test target and confirm the result.
  4. Check the exit code: 0 = OK, 1 = needs attention, 2 = error (see log), 9 = this copy is past its Valid until date.
  5. Roll out to a small group next, then everyone.

Rollback steps

Report mode changes nothing. Fix mode only starts stopped sites and application pools that are not on the ignore list. To undo, stop them again in IIS Manager or with Stop-Website and Stop-WebAppPool.

Version and change log

VersionDateChanges
1.0.0November 2026First release.