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):
<PROTOCOL> '/' <IP_ADDRESS> ':' <PORT> ':' [ <HOSTNAME> ]
PROTOCOL is one of http or https.IP_ADDRESS is a literal IP address, or * for all of the computer's IP addresses. This function does not validate if IPADDRESS is actually in use on the computer.PORT is the port to listen on.HOSTNAME is the website's hostname, for name-based hosting. If no hostname is being used, leave off the HOSTNAME part.Valid bindings are:
http/*:80:example.com
In some situations, when you add a website to an application pool that another website/application is part of, the new website will fail to load in a browser with a 500 error saying Failed to map the path '/'.. We've been unable to track down the root cause. The solution is to recycle the app pool, e.g. (Get-IisAppPool -Name 'AppPoolName').Recycle().
Beginning with Carbon 2.0.1, this function is available only if IIS is installed.
| 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
|
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 |
false | false | 0 |
| PassThru | SwitchParameter | Return a The |
false | false | False |
| Force | SwitchParameter | Deletes the website before installation, if it exists. Preserves default beheaviro in Carbon before 2.0. The |
false | false | False |
Install-IisWebsite -Name 'Peanuts' -PhysicalPath C:\Peanuts.com
Creates a website named Peanuts serving files out of the C:\Peanuts.com directory. The website listens on all the computer's IP addresses on port 80.
Install-IisWebsite -Name 'Peanuts' -PhysicalPath C:\Peanuts.com -Binding 'http/*:80:peanuts.com'
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 peanuts.com domain.
Install-IisWebsite -Name 'Peanuts' -PhysicalPath C:\Peanuts.com -AppPoolName 'PeanutsAppPool'
Creates a website named Peanuts that runs under the PeanutsAppPool app pool