I’m configuring IIS on some servers to add deny HTTP Verbs to the Request Filtering section. This was done using the following:

Add-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' -Filter 'system.webServer/security/requestFiltering' -Value @{VERB="OPTIONS";allowed="False"} -Name Verbs -AtIndex 0

…however, I want to be able to confirm the presence of this after it’s been configured. The following shows some properties but not the actual HTTP Verbs list:

Get-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter 'system.webServer/security/requestFiltering' -Name Verbs

I've since found the following command which does show a header for "Verbs" but it's empty regardless of "OPTIONS" being present in the IIS admin console:

Get-WebConfiguration system.webServer/security/RequestFiltering/verbs -Recurse | Select-Object Verbs

What do I need to add to list the verbs present?



Get-WebConfiguration -pspath 'MACHINE/WEBROOT/APPHOST' -filter 'system.webServer/security/requestFiltering/verbs/add' | ft verb,allowed

using the full Xpath to the XML node.

Sometimes it helps to look at the applicationhost.config file to figure out where exactly data is stored. You may use a Diff tool to see the differences after changing something in the UI.

To remove a specific verb, use:

Remove-WebConfigurationProperty  -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/security/requestFiltering/verbs" -name "." -AtElement @{verb='OPTIONS'}
  • Bang on again thanks Peter ;)....and thanks for the advice. – jshizzle Nov 24 '20 at 18:33
  • Further to this, how would I remove the verb if I wanted to back this out? – jshizzle Nov 25 '20 at 12:47
  • Thanks for the update Peter. I actually remember seeing the command Clear-WebConfigurationProperty in another thread but that removes all values in one go from my understanding so Remove-WCP is more suitable for this scenario. – jshizzle Nov 26 '20 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.