How do I remove IIS custom header using Powershell?

前端 未结 2 711
感动是毒
感动是毒 2021-01-05 08:58

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

2条回答
  •  心在旅途
    2021-01-05 09:20

    To remove the header on iis level:

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

    And for a specific site:

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

提交回复
热议问题