Search code examples
powershelliisiis-10

IIS IP Restriction Feature settings change with powershell


I'm trying to update the deny action type under feature settings in "IP Address and Domain Restrictions" in IIS using Powershell to Abort instead of Forbidden

I've run the following command in Powershell which has made the change in the ApplicationHost.config file in configuration editor:

Set-WebConfiguration -PSPath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/security/dynamicIpSecurity" -name "denyAction" -value "AbortRequest"

However, it doesn't seem to be changing the drop down value under feature settings in IIS gui itself but the change is reflected in Configuration Editor.

Not sure if I'm missing something or I've entering the wrong command to change this or something but I've tried restarting IIS after making the change, stopping IIS, making the change, then starting IIS again and I've run the set command between the start and stop IISCommitDelay commands but nothing seems to be changing it

I'm a bit new to IIS so any insight or advice will be greatly appreciated. Thanks.


Solution

  • If you want to change the "Deny Action Type" drop down value to Abort in "Edit Feature Settings" in "IP Address and Domain Restrictions" in iis, you need to run the following command in Powershell.

    Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/security/ipSecurity" -name "denyAction" -value "AbortRequest"
    

    The <ipSecurity> element corresponds to the content in "Edit Feature Settings".

    enter image description here

    The <dynamicIpSecurity> element corresponds to the content in "Dynamic IP Restriction Settings".

    enter image description here