IIS: Display all sites and bindings in PowerShell

sanjeev40084 picture sanjeev40084 · Mar 20, 2013 · Viewed 98.7k times · Source

I am documenting all the sites and binding related to the site from the IIS. Is there an easy way to get this list through a PowerShell script rather than manually typing looking at IIS?

I want the output to be something like this:

Site                          Bindings
TestSite                     www.hello.com
                             www.test.com
JonDoeSite                   www.johndoe.site

Answer

Christopher Douglas picture Christopher Douglas · Mar 20, 2013

Try this:

Import-Module Webadministration
Get-ChildItem -Path IIS:\Sites

It should return something that looks like this:

Name             ID   State      Physical Path                  Bindings
----             --   -----      -------------                  --------
ChristophersWeb 22   Started    C:\temp             http *:8080:ChristophersWebsite.ChDom.com

From here you can refine results, but be careful. A pipe to the select statement will not give you what you need. Based on your requirements I would build a custom object or hashtable.