Appcmd Command

Appcmd Command

Appcmd Command

  • General purpose IIS 7 command line administration tool
  • Allows all key IIS functionality to be managed from the command line or from scripts
  • Enables site admins to quickly automate server management tasks without writing code
  • The command is located at %windir%\system32\inetsrv\appcmd.exe
  • Type 'cd \windows\system32\inetsrv' at the command prompt before using appcmd.exe

Configuration Files

  • By default, Appcmd reads/writes configuration to the ApplicationHost.config file
  • Use the /commit:WEBROOT parameter to read/write changes to the root Web.config file
  • Use the /commit:MACHINE parameter to read/write changes to the Machine.config file

Appcmd Examples

Note: Use the full path C:\Windows\system32\inetsrv\appcmd for the command

  • Display whether HTTP Redirection is enabled in the ApplicationHost.config file:appcmd list config /section:httpRedirect
  • Display whether anonymous authentication is enabled in the root web.config file: appcmd list config /section:system.webServer/security/authentication/ anonymousauthentication /commit:WEBROOT
  • Display the syntax for listing info from sections of a configuration file: appcmd list config /section:?
  • Recycle the application pool: appcmd recycle apppool /
  • Create a new backup of IIS: appcmd add backup backupNameHere
  • List the existing IIS backups: appcmd list backup
  • Restore an existing IIS backup: appcmd restore backup backupNameHere
  • Restart a particular web site: appcmd start Site siteNameHere
  • Display the bindings and status of a site: appCmd.exe list site "siteNameHere"
  • Make a site configuration setting in the web.config of a site to enable directory browsing: appcmd.exe set config "siteNameHere/" /section:directoryBrowse /enabled:true
  • Make a site configuration setting in the applicationHost.config to enable directory browsing: appcmd.exe set config "siteNameHere/" /section:directoryBrowse /enabled:true /COMMIT:MACHINE/WEBROOT/APPHOST

Appcmd Notes

  • All configuration is stored in sections
    • Use the appcmd command to specify which section should be updated/edited
    • Set properties and specify the level where they should be set
  • By default, appcmd commands update the web.config file at the root of a site
  • A commit parameter can be used to force the configuration path to be written to applicationHost.config with a location tag to apply to a specific site