IIS Configuration: Disable Default Document


I’m able to query the default document list in IIS using the following:

Get-WebConfigurationProperty -Filter "//defaultDocument/files/add" -PSPath 'MACHINE/WEBROOT/APPHOST' -Name "value" | select value

…but I want to disable the default document feature altogether to address a vulnerability. I’ve not found much on disabling the feature via powershell but MS documentation says the following can be run to remove a value:

remove-webconfigurationproperty /system.webServer/defaultDocument -name files -atElement @{value="foo.html"}

Is this really the only way to disable the feature? I’ve not found anything that suggests it can simply be disabled like you can in the IIS administration console.

Sorted this out following the advice here: https://serverfault.com/questions/1043774/iis-configuration-via-powershell-disable-default-document/1043777?noredirect=1#comment1358762_1043777

Thanks for the update and sharing the solution.