IIS AppCmd Quick Reference

IIS appcmd is very handy for deployment automation of .NET web applications. The appcmd can be found at %systemroot%\system32\inetsrv or %systemroot%\\SysWOW64\inetsrv on web server. Please refer to IIS Administration Tools for details. The following is a quick reference for the most common usages of appcmd in web application deployment automation.

1. Add Site
appcmd add site /name:MySite /bindings:http://*:80 /physicalpath:”d:\MySitePath”
2. Add App Pool
appcmd add apppool /name:MyAppPool /managedRuntimeVersion:v4.0 (e.g. targeting .NET 4.0)
3. Set App Pool Credential
appcmd set config /section:applicationPools /[name='MyAppPool'].processModel.identityType:SpecificUser /[name='MyAppPool'].processModel.userName:MyDomain\MyAccount /[name='MyAppPool'].processModel.password:MyAccountPassword
4.Add App
appcmd add app /site.name:"MySite" /path:/MyApp /physicalpath:"d:\MySitePath\MyApp"
5. Assign/Change App Pool to an App
appcmd set app "MySite/MyApp" /applicationpool:MyAppPool
6. List (App, Site, AppPool, etc.)
appcmd list app
appcmd list site
appcmd list apppool
7. Enable/Disable Anonymous Authentication (True to Enable, False to Disable)
appcmd set config "MySite/MyApp" -section:system.webServer/security/authentication/anonymousAuthentication /enabled:"True" /commit:apphost
8. Enable Windows Authentication (True to Enable, False to Disable)
appcmd.exe set config "MySite/MyApp" -section:system.webServer/security/authentication/windowsAuthentication /enabled:"True" /commit:apphost
9. Change Windows Authentication Providers (NTLM or Negotiate)
appcmd set config MySite/MyApp -section:system.webServer/security/authentication/windowsAuthentication /~providers /commit:apphost (clear provider list)
appcmd set config MySite/MyApp -section:system.webServer/security/authentication/windowsAuthentication /-providers.[value='NTLM'] /commit:apphost (set to NTLM)
appcmd set config MySite/MyApp -section:system.webServer/security/authentication/windowsAuthentication /+providers.[value='Negotiate'] /commit:apphost (set to Negotiate)
10. Add Custom Header – for example, nosniff header or IE 7 compatiable header
appcmd  set config MySite -section:system.webServer/httpProtocol /+customHeaders.[name='X-Content-Type-Options',value='nosniff'] /commit:apphost
appcmd set config MySite -section:system.webServer/httpProtocol /+customHeaders.[name='X-UA-Compatible',value='IE=EmulateIE7'] /commit:apphost
11. Add Default Document - error if it exists already
appcmd set config "MySite/MyApp" /section:defaultDocument /+files.[value='default.asmx']
12. Delete App and Site - error if it doesn’t  exist
appcmd delete app "MySite/MyApp"
appcmd delete site "MySite"
13. Delete AppPool- error if it doesn’t exist or it is used by app
appcmd delete apppool MyAppPool
14. Backup and Restore IIS Settings
appcmd add backup MyBackup
appcmd restore backup MyBackup
15. HTTPS Binding if you are using HTTP over SSL
appcmd set site /site.name:"MyApp" /+bindings.[protocol='https',bindingInformation='*:443:MySSLCertificate']

Comments (5)
  1. shama says:

    Thanks, was looking for this command to clear provider list and got it here.  I am looking to move providers up/down in the provider list but using the command line. Do you know if this can be done?

  2. Sundaresan Thandavan says:

    Excellent. I was spending more time to get all these commands from various sites. Your blog helps a lot.



  3. Jagadeesh says:

    Is there a command add sever name to recycle app pool remotely?

  4. Tin J says:

    Thanks for posting this command list. Please add more

  5. Jagruti R says:

    I need to list the log files directory of IIS using a command line.

    I am trying below powershell command but it is giving the below error


    .appcmd list config /section:system.applicationHost/log -centralW3CLogFile.directory


    ( message:The attribute "centralW3CLogFile" is not supported in the current command usage. )

Comments are closed.

Skip to main content