Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

up vote 4 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.

share|improve this answer
5  
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
add comment

Powershell:

Import-Module WebAdministration 
New-Website -name "[name]" -HostHeader "[www.example.com]" -PhysicalPath "[c:\inetpub\example.com\]"

Using Powershell combined with the .NET assembles:

[Microsoft.Web.Administration.ServerManager]::OpenRemote($WebServer)

You can basically control every facet of the web site/web server.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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