Skip navigation

Configuring IIS 7.0 from the Command Line

Q: Is there an easy way to configure Microsoft IIS 7.0 Web server (i.e., the Web server that runs on Windows Server 2008 and Windows Vista) authentication settings from the command line? For example, I would like to enable/disable anonymous access to my Web server from the command line.

 

A: In IIS 7.0, you can leverage the Appcmd.exe command-line utility to configure Web server authentication settings from the command line. For example, to disable anonymous access at the IIS root level from the command line, you would use the following Appcmd command:

 

appcmd set config -section:anonymousAuthentication -enabled:false

 

To do the same for your IIS server’s default Web site, use the command

 

appcmd set config "Default Web Site/" -section:anonymousAuthentication -enabled:false

 

The anonymousAuthentication parameter in the previous commands corresponds to an IIS configuration setting (hence the use of the config parameter in the previous commands) that's stored in one of the IIS 7.0 XML-formatted configuration files. (Note that these files replace the IIS metabase, which is the configuration database that's used in earlier IIS versions.) The IIS 7.0 configuration files are called applicationHost.config, which is the global IIS Web server configuration file, and web.config at the different application/Web site levels in the IIS 7.0 application/Web site hierarchy. A good overview of the IIS 7.0 configuration files is available at http://mvolo.com/blogs/serverside/archive/2007/07/21/Anatomy-of-an-IIS7-configuration-path.aspx.

     

The Appcmd.exe tool is located in the %systemroot%\system32\inetsrv\ directory. Because this file system location isn't automatically part of a Server 2008 or Vista system’s PATH environment variable, you must use the full path to Appcmd.exe when executing Appcmd commands. You can also manually add the inetsrv directory to your machine’s PATH environment variable so that you can access AppCmd.exe from any file system location. A good introduction to the Appcmd.exe command-line utility is available at http://www.iis.net/articles/view.aspx/IIS7/Use-IIS7-Administration-Tools/Using-the-Command-Line/Getting-Started-with-AppCmd-exe and http://go.microsoft.com/fwlink/?LinkId=60957.

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish