Introduced
The IIS PowerShell name space includes such things as: Web-sites, Apps, Virtual directories, and application pools.
Using the built-in PowerShell cmdlets makes it easy to create a namespace entry and manage it.
Create a Web site
If you are familiar with PowerShell, you will know that under various PowerShell namespaces New-item cmdlet is often used to create
The new item. For example, the current command "New-item c:\TestDirectory" creates a new folder (although most people use New-item
Alias command "MD" or "MKDIR". Under the IIS 7.0 PowerShell namespace, New-item is also used to create new Web sites.
Parameters
When you create a file system path, you need to specify a path name. Unfortunately, this is not enough when you are currently creating a Web site. Except like
Network bindings is also required in addition to parameters such as file system paths. The following command is used to create a new Web site and use the dir command
To display:
PS iis:\sites> new-item iis:\sites\testsite-bindings @{protocol= "http"; bindinginformation= ": 80:TestSite"}- PhysicalPath C:\Test
PS iis:\sites> dir
Name ID State physical Path bindings
---- -- ----- ------------- --------
Default Web Site 1 started f:\inetpub\wwwroot http *:80:
Testsite 2 started c:\test http:80:testsite
The-physicalpath parameter is used directly here. However, you may ask:-bindings look so complicated?
Hashtable is typically used at construction time (learn more about PowerShell hash tables here). A key value pair in a hash table represents a
Sets the collection that reflects the related properties in the IIS Site Bindings section:
<bindings>
<binding protocol="http" bindingInformation=":80:TestSite" />
</bindings>
Now we've found a reason to use hash table: The IIS configuration can be extended using attributes. (See here for more information). You
Imagine using other attributes to extend the <binding> element node. This elasticity is provided by the key value pairs of the hash table.
Frankly speaking, the grammar is a bit complicated. We are considering encapsulating some typical tasks in Tech preview: such as the method or script to create a site.