Installs a website.


Install-IisWebsite [-Name] <String> [-PhysicalPath] <String> [[-Binding] <String[]>] [-AppPoolName <String>] [-SiteID <Int32>] [-PassThru] [-Force] [<CommonParameters>]


Install-IisWebsite installs an IIS website. Anonymous authentication is enabled, and the anonymous user is set to the website's application pool identity. Before Carbon 2.0, if a website already existed, it was deleted and re-created. Beginning with Carbon 2.0, existing websites are modified in place.

If you don't set the website's app pool, IIS will pick one for you (usually DefaultAppPool), and Install-IisWebsite will never manage the app pool for you (i.e. if someone changes it manually, this function won't set it back to the default). We recommend always supplying an app pool name, even if it is DefaultAppPool.

By default, the site listens on (i.e. is bound to) all IP addresses on port 80 (binding http/*:80:). Set custom bindings with the Bindings argument. Multiple bindings are allowed. Each binding must be in this format (in BNF):


Valid bindings are:

Beginning with Carbon 2.0.1, this function is available only if IIS is installed.

Related Commands


Name Type Description Required? Pipeline Input Default Value
Name String

The name of the website.

true false
PhysicalPath String

The physical path (i.e. on the file system) to the website. If it doesn't exist, it will be created for you.

true false
Binding String[]

The site's network bindings. Default is http/*:80:. Bindings should be specified in protocol/IPAddress:Port:Hostname format.

  • Protocol should be http or https.
  • IPAddress can be a literal IP address or *, which means all of the computer's IP addresses. This function does not validate if IPAddress is actually in use on this computer.
  • Leave hostname blank for non-named websites.
false false @('http/*:80:')
AppPoolName String

The name of the app pool under which the website runs. The app pool must exist. If not provided, IIS picks one for you. No whammy, no whammy! It is recommended that you create an app pool for each website. That's what the IIS Manager does.

false false
SiteID Int32

The site's IIS ID. IIS picks one for you automatically if you don't supply one. Must be greater than 0.

The SiteID switch is new in Carbon 2.0.

false false 0
PassThru SwitchParameter

Return a Microsoft.Web.Administration.Site object for the website.

The PassThru switch is new in Carbon 2.0.

false false False
Force SwitchParameter

Deletes the website before installation, if it exists. Preserves default beheaviro in Carbon before 2.0.

The Force switch is new in Carbon 2.0.

false false False

Return Values



Install-IisWebsite -Name 'Peanuts' -PhysicalPath C:\

Creates a website named Peanuts serving files out of the C:\ directory. The website listens on all the computer's IP addresses on port 80.


Install-IisWebsite -Name 'Peanuts' -PhysicalPath C:\ -Binding 'http/*'

Creates a website named Peanuts which uses name-based hosting to respond to all requests to any of the machine's IP addresses for the domain.


Install-IisWebsite -Name 'Peanuts' -PhysicalPath C:\ -AppPoolName 'PeanutsAppPool'

Creates a website named Peanuts that runs under the PeanutsAppPool app pool