In HTTP response I see some server headers that I need to filter at IIS level using Powershell. I know how to remove custom headers but I can't find a way to remove server headers.
Headers that I see in response.. Server type : XXXXXX Server version : XXXXXX Source : XXXXX Additional data : XXXXXX
This post explains how to remove custom headers and it works for me but I can't seem to find a way to rmeove server headers using powershell. How do I remove IIS custom header using Powershell?
Accoding to your description, I suggest you could try to use below powershell command to remove the IIS http response server header:
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site' -filter "system.webServer/security/requestFiltering" -name "removeServerHeader" -value "True"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/security/requestFiltering" -name "removeServerHeader" -value "True"
Notice:
The first being for the Default Web Site and the second will remove it from all web sites running on the server.
This is only worked from IIS10. If you use IIS8 or below, you could only use url rewrite to achieve your requirement.
Result:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.