【问题标题】:Find the http response headers for IIS using powershell使用 powershell 查找 IIS 的 http 响应标头
【发布时间】:2021-02-25 12:13:20
【问题描述】:

我想查找特定网站的自定义标题。

我可以使用以下命令查看原始属性。我认为这是所有网站的全球价值。我为一些网站创建了一些标题。但我无法查看它。是否有查看特定站点的命令。

>Get-IISConfigSection -SectionPath system.webServer/httpProtocol | Get-IISConfigCollection -CollectionName "customHeaders"

Attributes      : {name, value}
ChildElements   : {}
ElementTagName  : add
IsLocallyStored : True
Methods         : 
RawAttributes   : {[name, X-Powered-By], [value, ASP.NET]}
Schema          : Microsoft.Web.Administration.ConfigurationElementSchema

更新
我可以使用以下命令找到。

> Get-IISConfigSection -SectionPath system.webServer/httpProtocol -CommitPath "testsite" | Get-IISConfigCollection -CollectionName "customHeaders"

但我无法提取名称和值。 我使用了select-object rawattribute,但它给出了空{}

【问题讨论】:

    标签: windows powershell iis http-headers


    【解决方案1】:

    您可以使用Get-Website命令获取特定网站的配置信息:

    Get-Website -Name "Default Web Site"
    

    该命令会返回默认网站的配置信息。

    【讨论】:

    • 我试过了:Get-Website -Name "testsite"|获取-IISConfigSection -SectionPath system.webServer/httpProtocol |获取 IISConfigCollection -CollectionName“customHeaders”。但我收到错误:Get-IISConfigSection:输入对象不能绑定到命令的任何参数,因为命令不接受管道输入,或者输入及其属性与接受管道输入的任何参数都不匹配。
    • 上面的命令没有给出http响应头。 (system.webServer/httpProtocol/customHeaders)
    • 您可以尝试使用“httpProtocolSection.GetCollection”命令,此链接中有类似问题您可以参考:stackoverflow.com/questions/63175529/…
    • 是的,这就是我使用的命令(在上面的问题中)。问题是我希望它用于特定站点 - 例如:testsite。输出用于一般站点。
    • 您可以尝试使用“Get-IisHttpHeader -SiteName SopwithCamel”,该命令将返回 SopwithCamel 网站的 HTTP 标头。 Carbon 是一个 PowerShell 模块,用于自动配置 Windows 7、8、2008 和 2012,以及自动安装和配置 Windows 应用程序、网站和服务。关于Carbon的更多信息,可以参考这个链接:powershellgallery.com/packages/Carbon/2.7.0
    猜你喜欢
    • 1970-01-01
    • 2016-09-12
    • 1970-01-01
    • 2020-01-17
    • 1970-01-01
    • 2013-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多