Locating hostheaders on IIS using PowerShell.

      Comments Off on Locating hostheaders on IIS using PowerShell.

Sometimes you might want to find out what HostHeaders are being used with similar names on your server. For example when there are conflicts and/or duplicate HostHeaders. Especially when you have lots of sites with similar names this can be a real pain in the ass using the GUI. Lucky for us, PowerShell comes with some nifty cmdlets that can grab the desired information for you.

Retrieving the HostHeader information

The cmdlet that lets us retrieve the information we need is Get-WebBinding. You can either search for the required hostheader directly, or use wildcards for quicker searches. In this case, we can use the following command:

> Get-WebBinding -HostHeader *tovernaar*

protocol        bindingInformation        sslFlags
--------        ------------------        --------
http        :80:static.tovernaar.nl			0
http        :80:www.tovernaar.nl			0
http		:80:tovernaar.nl				0
http		:80:tovernaar.com				0
http		:80:www.tovernaar.com			0
http		:80:static.tovernaar.com		0

Since my own domain is working just fine for now you won’t notice anything strange in these results. Whenever you do encounter trouble you can get a quick overview using PowerShell. You can even use For-Each-Object to pipe your results trough and manipulate them even further.