Created
September 16, 2022 21:40
-
-
Save jcefoli/9d98c8c77a0ae0a918785eb8c6600a93 to your computer and use it in GitHub Desktop.
IIS Header Examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Import-Module WebAdministration | |
| # Add Custom Header - Server Level | |
| Add-WebConfigurationProperty -PSPath MACHINE/WEBROOT/APPHOST ` | |
| -Name . -Filter system.webServer/httpProtocol/customHeaders ` | |
| -AtElement @{name = "X-Custom" ; value = 'value' } | |
| #Remove Server: Microsoft-IIS/10.0 Header | |
| Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/security/requestFiltering" -name "removeServerHeader" -value "True" | |
| # Remove IIS Default X-Powered-By Header | |
| Clear-WebConfiguration "/system.webServer/httpProtocol/customHeaders/add[@name='X-Powered-By']" | |
| # Remove IIS Default X-AspNet-Version Header | |
| Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT' -Filter "system.web/httpRuntime" -name "enableVersionHeader" -value "False" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment