<< A B C D E F G H I J K L M N O P Q R S T U V W X Y Z



bindings, find all IPs for a server and sort by IP address

This works OK if you happen to already be on the web server in question

Import-Module WebAdministration
$sites = Get-ChildItem IIS:\sites
$bindings = $sites | foreach-object {$_.Bindings} | foreach-object {$_.Collection} | foreach-object {$_.BindingInformation}
$bindings | Sort-Object

But if you're not already on the web server in question, starting a remote session can speed things up. I also like to split out the various parts of the returned object into separate columns.

$serverName = "someWebServer"
$Session = New-PSSession -ComputerName $serverName
$block = {Import-Module WebAdministration
    $sites = Get-ChildItem -path IIS:\Sites
    $bindings = $sites | foreach-object {$_.Bindings} | foreach-object {$_.Collection} | foreach-object {$_.BindingInformation}
    $bindings | Select @{name="IP"; expression={$_.Split(":")[0]}}, @{name="port"; expression={$_.Split(":")[1]}}, @{name="domain" ; expression={$_.Split(":")[2]}} | sort domain | ft
Invoke-Command -Session $Session -ScriptBlock $block

In this case, I was most interested in sorting by domain. But Often I want to know if an IP address is being used, so I'll sort by that instead. Unfortunately, you can't pipe to an Out-GridView in a remote session and I haven't figured out yet how to return a variable's result to the local session so I can pipe that to an Out-GridView. So, I content myself with Format-Table.








IP addresses, list - see bindings, find all IPs for a server and sort by IP address