Retrieve a List Of Active Sites From IIS
20 Oct 2016I had reason to need a list of all the sites that were running on an IIS server and were "on". After much Googling, I was able to piece together the simple script below:
Import-Module webadministration
Get-ChildItem IIS:\Sites | where {$_.State -eq 'Started'} | select Name
This worked so well that I have setup the script to run weekly on our staging servers and email me the results. This allows me to audit the sites and turn off sites that I know we no longer need to have active. It is always best to keep the attack surface as small as possible. :)