Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In deploying a new version of our ASP.NET application, we need to set the authentication method for a particular page to be "Integrated only." We can do this from the IIS managment console, but would like to write a script (batch or powershell, doesn't matter) that will make the change to ensure that everything goes smoothly in the deployment.

The rest of the pages in the application will allow different authentication methods, but this particular page will only allow integrated.

In the same deployment, we also need to change the location of the custom error pages for all 401 errors, preferably also from the command line.

share|improve this question
up vote 5 down vote accepted

AdsUtil.VBS is your friend:

adsutil.vbs set  W3SVC/1/root/AuthNTLM true
adsutil.vbs set  W3SVC/1/root/AuthAnonymous false
adsutil.vbs set  W3SVC/1/root/AuthBasic  false
adsutil.vbs set  W3SVC/1/root/AuthPassport false
adsutil.vbs set  W3SVC/1/root/AuthMD5 false

Which is the same as:

adsutil.vbs set  W3SVC/1/root/AuthFlags 5

Note that <1> is your web site ID.

For CustomErrors, you need to update the root/HTTPErrors field which is actually a LIST item. David Wang has the appropriate script for this: chglist.vbs

chglist.vbs W3SVC/1/HttpErrors 404 404,*,URL,/CustomErrors/404.asp /COMMIT

For individual files, you can add them after the /Root/ Path:

adsutil.vbs set W3SVC/1/root/MyFile.txt/AuthFlags 5
share|improve this answer
Is it possible to set the authentication on one particular page rather than the whole web site? – Brien May 29 '09 at 17:36

You can control authentication from a web.config file. You would put the following in your web.config (from

   <!-- mode=[Windows|Forms|Passport|None] -->
   <authentication mode="Windows" />

Alternatively, you could check out the System.DirectoryServices API for IIS 5 & 6 ( or the Microsoft.Web.Administration API for IIS 7 (

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.