Search code examples
powershelliis-7

how to extract the text from a Microsoft.IIs.PowerShell.Framework.ConfigurationElement object


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?


Solution

  • 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