0

I am new to writing scripts and am currently writing a script which will automate populating the contents of a web configuration file. However, every time I try to add a deny tag, it always populates it as an allow tag.

I am doing

Add-WebConfiguration '/system.web/authorization' -location 'Blue.aspx' -PSPath $path -value @{accessType='Deny';users='*'}

in my script, but the web config keeps populating as

<system.web>
    <authorization>
        <allow users="*" />
    </authorization>
</system.web>

I want it to appear as

<system.web>
    <authorization>
        <deny users="*" />
    </authorization>
</system.web>

I have also been using this webpage for reference, but have not been able to find anything to help. I've tried a bunch of things to no avail. Any thoughts?

Toto
  • 89,455
  • 62
  • 89
  • 125
ash
  • 29
  • 3
  • 1
    https://stackoverflow.com/q/30135330/696808 Looks like you might need to use `Add-WebConfigurationProperty`. – Bacon Bits Jun 04 '21 at 18:30
  • Does this answer your question? [Managing IIS .Net Authorization Rules with a powershell script](https://stackoverflow.com/questions/30135330/managing-iis-net-authorization-rules-with-a-powershell-script) – mason Jul 09 '21 at 15:15

0 Answers0