Skip to content

Instantly share code, notes, and snippets.

@jcefoli
Created September 16, 2022 21:40
Show Gist options
  • Select an option

  • Save jcefoli/9d98c8c77a0ae0a918785eb8c6600a93 to your computer and use it in GitHub Desktop.

Select an option

Save jcefoli/9d98c8c77a0ae0a918785eb8c6600a93 to your computer and use it in GitHub Desktop.
IIS Header Examples
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