Iis – appcmd command to set anonymous authentication on a folder under a Web Application

appcmdiisiis-7web-server

I would like to run a command to set up anonymous authentication on a folder under a Web Application on IIS. I would like the particular folder to be the only thing affected. I don't want to change the anonymous authentication for the entire Web Application.

Edit 29. July 2013:
Still not having adequate answer 🙁 Adding some key facts:
– I need this in a script as part of installation process.
– I don't want to rely on IIS powershell snap-in.
– I know about possibility of setting this up via web config and I don't have a problem with that but I can't alter any config outside of my Web Application. I can't alter C:\Windows\System32\inetsrv\config\applicationHost.config, so, this option is out.

This can very easily be done via IIS Manager (GUI).

Best Answer

Use AppCmd to allow overriding section configuration in application Web.config:

%systemroot%\system32\inetsrv\APPCMD unlock config  /section:security/authentication/anonymousAuthentication

Unlocking a particular section will allow child Web.config in a particular directory to apply. Just keep in mind that unlocking the section is applied globally.