appcmd quick reference guide for iis 7 installed on win2k8 servers

12
AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

Upload: adelia-cox

Post on 25-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

Page 2: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

What is AppCMD

AppCMD is a replacement of IIS Admin Scripts (Commonly know as Vbs admin scripts for IIS) in IIS7 or Higher installed on WIn2k8 Server or higher. AppCmd.exe is the single command line tool for managing IIS 7 and above. It exposes all key server management functionality through a set of intuitive management objects that can be manipulated from the command line or from scripts.

Page 3: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

What AppCMD is Capable of

AppCmd enables you to easily control the server without using a graphical administration tool and to quickly automate server management tasks without writing code.

Some of the things you can do with AppCmd: Create and configure sites, apps, application pools, and virtual directories

Start and stop sites, and recycle application pools List running worker processes, and examine currently executing requests

Search, manipulate, export, and import IIS and ASP.NET configuration AppCmd also allows server administrators to build advanced management tasks simply by combining multiple simpler

AppCmd.exe commands, or reusing the output of the tool inside another program.

Page 4: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

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.

Page 5: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

AppCMD Quick reference

1. Add SiteAppCMD add site /name:MySite /bindings:http://*:80 /physicalpath:”d:\MySitePath”2. Add App PoolAppCMD add apppool /name:MyAppPool /managedRuntimeVersion:v4.0 (e.g. targeting .NET 4.0)3. Set App Pool CredentialAppCMD set config /section:applicationPools /[name='MyAppPool'].processModel.identityType:SpecificUser /[name='MyAppPool'].processModel.userName:MyDomain\MyAccount /[name='MyAppPool'].processModel.password:MyAccountPassword

Page 6: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

AppCMD Quick reference

4.Add AppAppCMD add app /site.name:"MySite" /path:/MyApp /physicalpath:"d:\MySitePath\MyApp"5. Assign/Change App Pool to an AppAppCMD set app "MySite/MyApp" /applicationpool:MyAppPool6. List (App, Site, AppPool, etc.)AppCMD list appAppCMD list siteAppCMD list apppool7. 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

Page 7: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

AppCMD Quick reference

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:apphost9. 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)

Page 8: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

AppCMD Quick reference

10. Add Custom Header – for example, nosniff header or IE 7 compatiable headerAppCMD set config MySite -section:system.webServer/httpProtocol /+customHeaders.[name='X-Content-Type-Options',value='nosniff'] /commit:apphostAppCMD set config MySite -section:system.webServer/httpProtocol /+customHeaders.[name='X-UA-Compatible',value='IE=EmulateIE7'] /commit:apphost11. Add Default Document - error if it exists alreadyAppCMD set config "MySite/MyApp" /section:defaultDocument /+files.[value='default.asmx']12. Delete App and Site - error if it doesn’t existAppCMD delete app "MySite/MyApp"AppCMD delete site "MySite"

Page 9: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

AppCMD Quick reference

13. Delete AppPool- error if it doesn’t exist or it is used by appAppCMD delete apppool MyAppPool

14. Backup and Restore IIS SettingsAppCMD add backup MyBackupAppCMD restore backup MyBackup

15. HTTPS Binding if you are using HTTP over SSLAppCMD set site /site.name:"MyApp" /+bindings.[protocol='https',bindingInformation='*:443:MySSLCertificate']

Page 10: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

AppCMD Quick referenceHow About Backup and restore option available in IIS .

There are times when we IIS gets corrupted and needs to be recovered , requires a quick workaround specially in cases where availability is on high priority. Below are the steps through which IIS can be recovered in Seconds!!!

Page 11: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

AppCMD Quick reference1) Creating a backup :To create a backup, simply type in:

>AppCmd Add Backup "BackupName" You can omit the name, in which case AppCmd is going to generate the backup name automatically using the current date and time. When a backup is created, the following happens: 1.A directory with the backup name is created under the %windir%system32inetsrvbackup directory. 2.AppCmd copies the current configuration files into the backup directory, including applicationHost.config (IIS global configuration), administration.config (Admin Tool's configuration), metabase.xml and mbschema.xml. The last two files contain the metabase data that is still used by some IIS services including SMTP and FTP, that have not been migrated to the new configuration system. AppCmd only backs up the files that are there, so if you delete any of these files, and then make a backup, the backup will not contain the missing files.

Page 12: AppCMD Quick Reference Guide for IIS 7 installed on Win2k8 Servers

AppCMD Quick reference2) Managing existing backups To list the backups that exist on the server, type in: >AppCmd List Backup This will list the backup objects, including their names that can be used to restore or delete them. To delete any of these backups if its no longer needed, type in: >AppCmd List Backup "BackupName"3) Restoring a backup To restore a backup, type in:>AppCmd Restore Backup "BackupName"This will stop IIS (equivalent to calling IISRESET.EXE /STOP), and overwrite the server's state with the files in the specified backup directory. Then, IIS will be re-started (equivalent to calling IISRESET.EXE /START).