Created
February 25, 2021 12:25
-
-
Save lars-erik/18ff0634d7683ff129f4eea6ef527fa3 to your computer and use it in GitHub Desktop.
List all IIS sites (Win 2012 PS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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