Skip to content

Instantly share code, notes, and snippets.

@jetstreamin
Created July 8, 2015 20:02
Show Gist options
  • Save jetstreamin/c82862e6c4a0e334a2e3 to your computer and use it in GitHub Desktop.
Save jetstreamin/c82862e6c4a0e334a2e3 to your computer and use it in GitHub Desktop.
appcmd most common commands
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']
@ALiwoto
Copy link

ALiwoto commented Jan 2, 2023

Hi there @jetstreamin
Just wanted to thank you for making this gist :) you saved me a lot of time! I almost owe you my job.

@toPrabhat
Copy link

toPrabhat commented Jun 21, 2023

Thanks @jetstreamin for sharing all useful commands at single place. Really useful.
Just wanted to check, do you have any idea how to apply a SSL Certificate on created site using same appcmd command. TIA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment