如何使用 Powershell 删除 IIS 自定义标头? [英] How do I remove IIS custom header using Powershell?

查看:14
本文介绍了如何使用 Powershell 删除 IIS 自定义标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个将网站部署到 IIS 7 的 powershell 脚本.我想使用 powershell 中的 Web 管理模块而不是 appcmd 执行以下命令来删除自定义标头.如何在不使用 appcmd 的 powershell 中执行此命令?

I am writing a powershell script that deploys a website to IIS 7. I would like to do the following command to remove a custom header using the Web-Administration module in powershell rather than with appcmd. How do I do this command in powershell not using appcmd?

appcmd set config /section:httpProtocol /-customHeaders.[name='X-Powered-By']

推荐答案

移除 iis 级别的标头:

To remove the header on iis level:

Remove-WebConfigurationProperty -PSPath MACHINE/WEBROOT/APPHOST  
                                -Filter system.webServer/httpProtocol/customHeaders 
                                -Name . 
                                -AtElement @{name='X-Powered-By'}

对于特定网站:

Remove-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST/Default Web Site'
                                -Filter system.webServer/httpProtocol/customHeaders
                                -Name .
                                -AtElement @{name='X-Powered-By'}

这篇关于如何使用 Powershell 删除 IIS 自定义标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆