4

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?

1 Answer 1

5

Try:

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'}
3
  • Bang on again thanks Peter ;)....and thanks for the advice.
    – jshizzle
    Commented Nov 24, 2020 at 18:33
  • Further to this, how would I remove the verb if I wanted to back this out?
    – jshizzle
    Commented Nov 25, 2020 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
    Commented Nov 26, 2020 at 0:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .