I couldn't find anything that was explicit on how to do this, so, I will throw it out there. The task is this: create a new website with the IP Address set to "All Unassigned". If you do this manually via the IIS Administration MMC it's pretty straightforward. In Powershell, however, I was unclear on how to do the "All Unassigned" part. This component essentially means using the wildcard (*) character for IP Address. To do this, make sure you have the WebAdministration module loaded, then, run this:
New-Website -Name "Test Website 1" -IPAddress "*" -HostHeader "www.testwebsite1.com" -PhysicalPath "C:\test"
When you run this command, you should get this result:
Name ID State Physical Path Bindings
---- -- ----- ------------- --------
Test Website 1 4 Started C:\test http *:80:www.testwebsite1.com
If you want to force the binding (the technical term for the IIS component specifying protocol, header, port, and, site name) use this approach. Notice the -SSL switch:
New-Website -Name "Test Website 2" -IPAddress "*" -HostHeader "www.testwebsite2.com" -PhysicalPath "C:\test" -SSL
With this approach, you should see this:
Name ID State Physical Path Bindings
---- -- ----- ------------- --------
Test Website 2 5 Stopped C:\test https *:80:www.testwebsite2.com
Be aware that you have to specify port 443 explicitly when you use the -SSL switch, otherwise, you will merely get a binding with the https protocol on port 80. This can work, but, is not standard practice. The appropriate command would be:
New-Website -Name "Test Website 3" -IPAddress "*" -HostHeader "www.testwebsite3.com" -PhysicalPath "C:\test" -SSL -Port 443
which, in turn, gives you this:
Name ID State Physical Path Bindings
---- -- ----- ------------- --------
Test Website 3 3 Started C:\test https *:443:www.testwebsite3.com
Note that I highlighted the binding and port in website 2 and website 3 to differentiate between the two.
0 comments:
Post a Comment