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
The Get-IISSite cmdlet gets information about Internet Information Services (IIS) web sites and their current status and other key information. If you a request a specific site or a comma delimited list of sites, only those whose names are passed as an argument are returned.
5] Using Windows Powershell First, open Windows Powershell by searching for Powershell in the Cortana search box and run it with Administrator level privileges. It will look similar to this, Hence, you will find the version of IIS installed on your computer using Windows PowerShell. Hope this helps!
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.
Try something like this to get the format you wanted:
Get-WebBinding | % { $name = $_.ItemXPath -replace '(?:.*?)name=''([^'']*)(?:.*)', '$1' New-Object psobject -Property @{ Name = $name Binding = $_.bindinginformation.Split(":")[-1] } } | Group-Object -Property Name | Format-Table Name, @{n="Bindings";e={$_.Group.Binding -join "`n"}} -Wrap
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With