如何使用Powershell获取网站HostHeader

col*_*joe 2 powershell powershell-2.0 iis-7.5 web

我正在尝试使用powershell为任何安装的网站提取主机.一旦我失败了,我想专门针对使用端口80和端口443的网站的hostHeaders.

到目前为止,我能够使用

get-webbinding cmdlet

从网站上提取一些信息,但我不确定如何使用它来查询网站上的HostHeader信息.在get-webbinding命令的输出中,我将主机头视为bindingInformation列的一部分,但我不确定如何获取主机头信息.

但是当我通过网站查询时

get-webbinding -HostHeader (hostHeaderName)

我收到信息,所以我相信有一种方法可以使用get-webbinding只查询hostHeader信息.

如果有其他方式来获取此信息,请告诉我.我也没有运气试图使用

get-website

man*_*lds 7

你将不得不分割bindingInformation:,并获得最后一部分:

Get-WebBinding | select -expand bindingInformation | %{$_.split(':')[-1]}
Run Code Online (Sandbox Code Playgroud)