如果我在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)
如何将此对象的内容提取为有用的格式?
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)
| 归档时间: |
|
| 查看次数: |
4144 次 |
| 最近记录: |