如何从Microsoft.IIs.PowerShell.Framework.ConfigurationElement对象中提取文本

tor*_*yan 5 powershell iis-7

如果我在powershell中运行命令:

C:\Get-Website
Run Code Online (Sandbox Code Playgroud)

它输出

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
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试只选择绑定:

C:\Get-Website | where {$_.Name -eq "Default Web Site"} | select Bindings
Run Code Online (Sandbox Code Playgroud)

它返回:

bindings : Microsoft.IIs.PowerShell.Framework.ConfigurationElement
Run Code Online (Sandbox Code Playgroud)

如何将此对象的内容提取为有用的格式?

And*_*ndi 9

bindings属性是一个集合,因此您必须使用以下ExpandProperty参数:

Get-Website -Name "Default Web Site" | select -ExpandProperty Bindings
Run Code Online (Sandbox Code Playgroud)

进一步向下钻取:

get-website -name "Default Web Site" | select -ExpandProperty Bindings | Select -ExpandProperty Collection
Run Code Online (Sandbox Code Playgroud)