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.
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.
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.
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:']
.
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.