Powershell equivalent to this AppCmd command?


  • Hi,

    I am trying to do the equivalent of this appcmd command in powershell:

    C:\windows\System32\inetsrv\appcmd.exe set config "CFAdmin" -section:system.webServer/security/requestFiltering /-"denyUrlSequences.[sequence='/testing']"

    Basically at the top level in IIS I have a denyUrlSequences set for all websites for the url sequence "/testing" and I want only one website to override that setting and allow the path in the URL.

    Anyone got any ideas?


    Monday, July 11, 2011 2:28 PM


  • that should work for you too:


    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration") | Out-Null
    $serverManager = new-object Microsoft.Web.Administration.ServerManager
    $config = $serverManager.GetWebConfiguration("test");
    $requestFilteringSection = $config.GetSection("system.webServer/security/requestFiltering");
    $denyUrlSequencesCollection = $requestFilteringSection.GetCollection("denyUrlSequences");
    $addElement = $denyUrlSequencesCollection.CreateElement("add");
    $addElement["sequence"] = "/testing";

    • Marked as answer by Technika Monday, July 11, 2011 3:49 PM
    Monday, July 11, 2011 3:22 PM

All replies