Created
June 18, 2016 01:27
-
-
Save JosephMaxwell/f69f2384749c9d334102923e1cb68e93 to your computer and use it in GitHub Desktop.
IIS Site Creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[Parameter(Mandatory=$true)string]$directoryPath, | |
[Parameter(Mandatory=$true)string]$iisAppName, | |
[string]$iisAppPoolName = "Default", | |
[string]$iisAppPoolDotNetVersion = "v4.5" | |
) | |
Import-Module WebAdministration | |
#navigate to the app pools root | |
cd IIS:\AppPools\ | |
#check if the app pool exists | |
if (!(Test-Path $iisAppPoolName -pathType container)) | |
{ | |
#create the app pool | |
$appPool = New-Item $iisAppPoolName | |
$appPool | Set-ItemProperty -Name "managedRuntimeVersion" -Value $iisAppPoolDotNetVersion | |
} | |
#navigate to the sites root | |
cd IIS:\Sites\ | |
#check if the site exists | |
if (Test-Path $iisAppName -pathType container) | |
{ | |
return | |
} | |
#create the site | |
$iisApp = New-Item $iisAppName -bindings @{protocol="http";bindingInformation=":80:" + $iisAppName} -physicalPath $directoryPath | |
$iisApp | Set-ItemProperty -Name "applicationPool" -Value $iisAppPoolName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment