IIS Sites Provisioning PowerShell Scripts. These are 6 PowerShell Scripts to help you automate the provisioning of AppPools, Sites, Applications, Virtual Directories, and Bindings. They use the Microsoft.Web.Administration managed code namespace interfaces to provision these objects. Here is an example for each of them:
4.1. To create any number of AppPools, Sites, Applications, Virtual Directories, and Bindings arranged in accordance to a configuration data file use Sample_AppPool_Site_AppCreation. This script calls all the others to create each object in accordance to the configuration data found in the ProvisioningConfig.xml XML file.
Example:
Sample_AppPool_Site_AppCreation
Example of a ProvisioningConfig.xml XML file:
<Script>
<ApplicationPool>
<Site Name="DAP1Site2" PhysicalPath="C:\Content\DAP1Site2">
<Application PhysicalPath="C:\Content\DAP1Site2\App1" RelativePath="/App1">
<VirtualDirectory PhysicalPath="C:\Content\Logs" RelativePath="/App1/VDir"/>
</Application>
<Application PhysicalPath="C:\Content\DAP1Site2\App2" RelativePath="/App2">
</Application>
<Binding Port="80" BindingInfo="www.DAP1Site2.com" Protocol="http"/>
<Folder name="C:\Content\DAP1Site2" quota="50mb">
<Permission>
<User>Administrators</User>
<Capability>F</Capability>
</Permission>
</Folder>
</Site>
</ApplicationPool>
</Script>
4.2. To create AppPools use CreateIISAppPool PoolName username password. If you do not provide username and password it will use the current user.
Example:
CreateIISAppPool "DemoAppPool1" "" ""
4.3. To create a Site use CreateIISSite SiteName PhysicalPath PoolName ID.
Example:
CreateIISSite "DAP1Site1" "C:\Content\DAP1Site1" "DemoAppPool1" 1702121
4.4. To create an Application on a site use CreateIISApplicationOntoSite PhysicalPath RelativePath SiteName PoolName.
Example:
CreateIISApplicationOntoSite "C:\Content\DAP1Site1\App1" "/App1" "DAP1Site1" "DemoAppPool1"
4.5. To create a Virtual Directory for an application use CreateIISVDirOntoApplication ApplicationPhysicalPath PhysicalPath SiteName RelativePath.
Example:
CreateIISVDirOntoApplication "C:\Content\Logs" "/App1/VDir" "DAP1Site1" "/App1"
4.6. To create a Binding for a Site use CreateIISBindingOntoSite SiteName Port BindingInfo Protocol.
Example:
CreateIISBindingOntoSite "DAP1Site1" 80 "www.DAP1Site2.com" "http"