Skip to content

Instantly share code, notes, and snippets.

@lars-erik
Created February 25, 2021 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lars-erik/18ff0634d7683ff129f4eea6ef527fa3 to your computer and use it in GitHub Desktop.
Save lars-erik/18ff0634d7683ff129f4eea6ef527fa3 to your computer and use it in GitHub Desktop.
List all IIS sites (Win 2012 PS)
import-module webadministration
$sites = Get-ChildItem -path IIS:\Sites
$mappedSites = $sites | % {
$bindings = try { ($_.Bindings.Collection | % {$_.bindingInformation}) } catch { @() }
if ($bindings -eq $null) { $bindings = @() }
[PSCustomObject]@{ `
Name=$_.Name; `
Id=$_.Id; `
State=$_.State; `
Path=$_.PhysicalPath; `
Bindings= [System.String]::Join(";", $bindings)
}
}
$mappedSites | ft
$mappedSites | convertto-csv | set-content c:\temp\sites.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment