List web sites with PowerShell
PS> Import-Module WebAdministration
PS> Get-ChildItem -Path IIS:\Sites
But that wasn’t working for me, the columns wrapped in a way that was a pain to reformat and I wanted more information.
So I decided to get all of the columns
PS> Get-ChildItem -Path IIS:\Sites | Format-Table -Property * -AutoSize | Out-String -Width 1300 | Out-File sites20160308-wide.txt
But a lot of those fields were either redundant or didn’t tell me much, plus NotePad.exe wraps text at the thousandth column whether there’s a line break or not. So I pulled out all of the columns, then eliminated the ones that weren’t likely to be useful to me.
PS> Get-ChildItem -Path IIS:\Sites | select name, id, serverAutoStart, state, applicationPool, enabledProtocols, physicalPath, Attributes, ChildElements, Methods, logFile, traceFailedRequestsLogging | Format-Table -Property * -AutoSize | Out-String -Width 900 | Out-File sites20160308-subset.txt
The next project in this series will be to in-line decode the fields logFile and traceFailedRequestsLogging so I can store that output and have a good snapshot of how IIS is configured. (Both of those fields output as “Microsoft.IIs.PowerShell.Framework.ConfigurationElement” which I expect I can turn in to something useful when I have more time.)