So what is Appcmd.exe?
This is "one" command line tool to administer IIS7. In IIS6 several of admin task were done using several scattered VBS script files. This made it difficult to find out what script needs to be run for eg. to get list of worker processes.
So IIS7 is powered with Appcmd.exe which provides all the options you need to administer IIS7.
Following are the options/categories available from a high level
Lets see how we can use it with an example
When I installed LH Server Beta (I rebuild my box quite frequently) I wanted to see how it's like to have 1000 websites running on IIS7.
So I created 1000 websites on my box.
Good scenario to use Appcmd.exe and also my MS-DOS experience. No I'm not gone nutts to create it using the UI :)
Steps required
Keep in mind I'm not talking about Server but my desktop machine. Yea its got 2GB RAM though.
Steps below
FOR command is a batch file loop which simply works like 'for' loop in your favorite language
FOR /L %i IN (2,1,1000) DO createsite.cmd %i
is equivalent to the following in C
for ( i=2; i <= 1000; i++ ) createsite( i );I started value of 'i' from 2 because "Default Website" has Site ID 1.
Hit enter and wait till the folders and websites are created for each iteration.
Bingo !!! 1000 websites ready to be administered or tested.
So the result would be E:\Websites folder would have folders called Site2, Site3 etc... and in IIS there would be sites with name Site2, Site3 etc...
Lets revisit the appcmd command above once again
appcmd add site /name:"Site%1" // website name/id:%1 // Site ID/bindings:http/:*:80:site%1 // site would have "All Unassigned" including host header with the site name/physicalPath:"E:\Websites\Site%1" // Pointing to the physical folder for that site
appcmd start site "Site%1" // pretty straight forward, it starts the website
What else can I do to extend this scenario?
Some other useful command options
Create BackupC:\>appcmd add backup "backup before screwup"BACKUP object "backup before screwup" added
List BackupC:\>appcmd list backupBACKUP "backup before screwup"
Restore from BackupC:\>appcmd restore backup "backup before screwup"Restored configuration from backup "backup before screwup"
Currently Executing RequestsC:\>appcmd list requestREQUEST "fa00000080000487" (url:GET /highcpu.asp, time:1903 msec, client:localhost)
Will add more of this later...