如果我在powershell中运行该命令:
C:\Get-Website它的输出
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但是如果我尝试只选择绑定:
C:\Get-Website | where {$_.Name -eq "Default Web Site"} | select Bindings它返回:
bindings : Microsoft.IIs.PowerShell.Framework.ConfigurationElement如何将此对象的内容提取为有用的格式?
发布于 2012-02-15 01:43:23
bindings属性是一个集合,因此您必须使用ExpandProperty参数:
Get-Website -Name "Default Web Site" | select -ExpandProperty Bindings要进一步深入,请执行以下操作:
get-website -name "Default Web Site" | select -ExpandProperty Bindings | Select -ExpandProperty Collection发布于 2020-03-25 23:58:02
最近,我正在使用类似的命令,但用于列出所有站点及其绑定。在IIS中,我是这样做的:
get-childItem |
select * , @{Name="SiteBindings"; Expression = {($_.Bindings.Collection | %{$_.protocol + " " + $_.BindingInformation} | Out-String).replace("`r","" ) }}注意替换(“`r”,"“)。如果您需要导出为CSV,则需要使用它。
发布于 2021-06-16 06:12:09
如果您不想从Get-Website开始,也可以使用Get-WebBinding cmdlet。
Import-Module WebAdministration
Get-WebBinding这将显示所有网站的所有绑定信息,您可以从那里进一步筛选。
下面是运行上述命令的示例输出。
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.ConfigurationElementSchemahttps://stackoverflow.com/questions/9281565
复制相似问题