在IIS7中,增加了一个非常有用的基于命令行方式的通用IIS的管理工具,叫做appcmd。利用该cmd可以完成applicationhost.config的backup, restore等等工作,功能非常强大。
以下是appcmd.exe的usage:
34APPCMD(command)(object-type)<identifier></parameter1:value1>56Supportedobjecttypes:
78SITEAdministrationofvirtualsites
9APPAdministrationofapplications
10VDIRAdministrationofvirtualdirectories
11APPPOOLAdministrationofapplicationpools
12CONFIGAdministrationofgeneralconfigurationsections
13WPAdministrationofworkerprocesses
14REQUESTAdministrationofHTTPrequests
15MODULEAdministrationofservermodules
16BACKUPAdministrationofserverconfigurationbackups
17TRACEWorkingwithfailedrequesttracelogs
1819(Tolistcommandssupportedbyeachobjectuse/?,e.g.'appcmd.exesite/?')
2021Generalparameters:
2223/?Displaycontext-sensitivehelpmessage.
2425/text<:value>Generateoutputintextformat(default).
26/text:*showsallobjectpropertiesindetailview.
27/text:<attribute>showsthevalueofthespecified
28attributeforeachobject.
29/xmlGenerateoutputinXMLformat.
30Usethistoproduceoutputthatcanbesenttoanother
31commandrunningin/inmode.
32/inor-ReadandoperateonXMLinputfromstandardinput.
33Usethistooperateoninputproducedbyanother
34commandrunningin/xmlmode.
35/config<:*>Showconfigurationfordisplayedobjects.
36/config:*alsoincludesinheritedconfiguration.
37/metadataShowconfigurationmetadatawhendisplayingconfiguration.
3839/commitSetconfigpathwhereconfigurationchangesaresaved.
40Canspecifyeitheraspecificconfigurationpath,"site",
41"app","parent",or"url"tosavetotheappropriateportion
42ofthepathbeingeditedbythecommand,"apphost","webroot",
43or"machine"forthecorrespondingconfigurationlevel.
44/debugShowdebugginginformationforcommandexecution.
4546Use"!"toescapeparametersthathavesamenamesasthegeneralparameters,
47like"/!debug:value"tosetaconfigpropertynamed"debug".
48
该命令支持的对象上表已经列出,包括:
1.Site,
其supported cmd包括:
45APPCMD(command)SITE<identifier><-parameter1:value1>67Supportedcommands:
89listListvirtualsites
10setConfigurevirtualsite
11addAddnewvirtualsite
12deleteDeletevirtualsite
13startStartvirtualsite
14stopStopvirtualsite
1516(Togethelpforeachcommanduse/?,e.g.'appcmd.exeaddsite/?'.)
1718
2. App
45APPCMD(command)APP<identifier><-parameter1:value1>67Supportedcommands:
89listListapplications
10setConfigureapplication
11addAddnewapplication
12deleteDeleteapplication
1314(Togethelpforeachcommanduse/?,e.g.'appcmd.exeaddsite/?'.)
15
3. Request
45APPCMD(command)REQUEST<identifier><-parameter1:value1>67Supportedcommands:
89listListactiveHTTPrequests
1011(Togethelpforeachcommanduse/?,e.g.'appcmd.exeaddsite/?'.)
1213
4BackUp
34APPCMD(command)BACKUP<identifier><-parameter1:value1>56Supportedcommands:
78listListexistingconfigurationbackups
9addCreateaconfigurationbackup
10deleteDeleteaconfigurationbackup
11restoreRestoreaconfigurationbackup
1213
e.g 将iis server的相关配置backup为cleaninstall,然后将该cleaninstall重新装载
appcmdadd backup cleaninstall //create a backup named as "cleaninstall"
appcmd restore backup cleaninstall //restore the specific backup "cleaninstall"
还有其他supported object,每个supported object都有其supported cmd,在此不一一列举了。