6

If I run the command in powershell:

C:\Get-Website

it outputs

Name             ID   State      Physical Path                  Bindings
----             --   -----      -------------                  --------
Default Web Site 1               %SystemDrive%\inetpub\wwwroot  http *:80:
                                                                net.tcp 808:*
                                                                net.pipe *
                                                                net.msmq localhost
                                                                msmq.formatname 
                                                                localhost

But if I try to select just the Bindings:

C:\Get-Website | where {$_.Name -eq "Default Web Site"} | select Bindings

It returns:

bindings : Microsoft.IIs.PowerShell.Framework.ConfigurationElement

How do I extract the contents of this object into a useful format?

3 Answers 3

9

The bindings property is a collection so you have to use the ExpandProperty parameter:

Get-Website -Name "Default Web Site" | select -ExpandProperty Bindings

To drill down further:

get-website -name "Default Web Site" | select -ExpandProperty Bindings | Select -ExpandProperty Collection
Sign up to request clarification or add additional context in comments.

Comments

1

Recently I was working on similar command but for list all Sites and its bindings. In IIS this is what i did :

get-childItem | 
select * , @{Name="SiteBindings"; Expression = {($_.Bindings.Collection | %{$_.protocol + "  " + $_.BindingInformation} | Out-String).replace("`r","" ) }}

Note the replace("`r","" ). It is needed if you need to export to CSV.

Comments

0

There's also the Get-WebBinding cmdlet that can be used if you don't want to start from Get-Website.

Import-Module WebAdministration

Get-WebBinding

This will display all of the binding info for all websites, and you can filter it down further from there.

Here's sample output of running the above command.

protocol             : http
bindingInformation   : *:80:
sslFlags             : 0
isDsMapperEnabled    : False
certificateHash      :
certificateStoreName :
ItemXPath            : /system.applicationHost/sites/site[@name='Default Web Site' and @id='1']
RunspaceId           : b7052f71-a213-437c-a97f-00fb9fa84a7f
Attributes           : {Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute,
                       Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute,
                       Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute,
                       Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute…}
ChildElements        : {}
ElementTagName       : binding
Methods              : {Microsoft.IIs.PowerShell.Framework.ConfigurationMethod,
                       Microsoft.IIs.PowerShell.Framework.ConfigurationMethod,
                       Microsoft.IIs.PowerShell.Framework.ConfigurationMethod,
                       Microsoft.IIs.PowerShell.Framework.ConfigurationMethod…}
Schema               : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.