up vote 1 down vote favorite
share [g+] share [fb]

I want to be able to create a new website with a new host header (which I can obviously do using the IIS Manager) from the command line so that it can be scripted.

Essentially what you can do with iisweb on IIS 6.

link|improve this question
feedback

2 Answers

up vote 2 down vote accepted

Use built-in appcmd, like this - using the bindings argument a host header can be specified:

appcmd add site /name:contoso /id:2 /physicalPath:c:\contoso /bindings:http/*:80: marketing.contoso.com

The variable name string is the name, and the variable id uint is the unsigned integer that you want to assign to the site. The variables name string and id uint are the only variables that are required when you add a site in Appcmd.exe. The variable bindings string contains information that is used to access the site, and it should be in the form of protocol/IP_address:port:host_header.

link|improve this answer
2  
One thing I found handy was adding multiple bindings in a single call. To do so, wrap each binding in quotes and comma-separate them: appcmd add site /name:contoso /bindings:"http/*:80:","https/*:443:" /physicalPath:C:\contoso. Otherwise, you have to do a separate call for each: appcmd set site /site.name:"G4" /+bindings.[protocol='https',bindingInformation='*:443:']. – patridge Jul 14 '10 at 16:32
feedback

I found a great article on IIS Serverside which seems to walk through the process.

(I'll come back and update this answer when I have a short walk-through.)

link|improve this answer
+1 for the serverside article, very informative. – Sumit Ghosh Feb 16 '11 at 7:48
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.