Create Web sites, Web applications, virtual paths, and application pools using IIS 7.0 PowerShell

Source: Internet
Author: User
Tags hash

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.