Created
August 3, 2015 13:51
-
-
Save christopherbauer/cd2d9ee64f3c4baa39b6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Import-Module WebAdministration | |
| if ($OctopusParameters -eq $null) | |
| { | |
| $OctopusParameters = @{ | |
| OctopusWebSiteName = "Default Web Site\SiteName" | |
| ApplicationPoolName = "AppPoolName" | |
| UseCustomAppPoolUser = false | |
| }; | |
| } | |
| $applicationPoolName = $OctopusParameters["ApplicationPoolName"] | |
| $appPoolPath = "IIS:\AppPools\$applicationPoolName" | |
| if (!(Test-Path $appPoolPath)) | |
| { | |
| New-WebAppPool -Name $applicationPoolName | |
| } | |
| else | |
| { | |
| Write-Host "Application pool '$applicationPoolName' exists." | |
| } | |
| Set-ItemProperty -Path $appPoolPath -Name "managedRuntimeVersion" -Value "v4.0" | |
| if ($OctopusParameters["UseCustomAppPoolUser"] -eq $true) | |
| { | |
| Set-ItemProperty -Path $appPoolPath -Name "processmodel.identityType" -Value "3" | |
| Set-ItemProperty -Path $appPoolPath -Name "processmodel.username" -Value $OctopusParameters["ApplicationPoolUsername"] | |
| Set-ItemProperty -Path $appPoolPath -Name "processmodel.password" -Value $OctopusParameters["ApplicationPoolPassword"] | |
| } | |
| Set-ItemProperty -Path $appPoolPath -Name "autoStart" -Value "true" | |
| Set-ItemProperty -Path $appPoolPath -Name processModel.idleTimeOut -value ([TimeSpan]::FromMinutes(0)) | |
| $websiteName = $OctopusParameters["OctopusWebSiteName"] | |
| $sitePath = "IIS:\Sites\$websiteName" | |
| if (!(Get-Item $sitePath -ErrorAction SilentlyContinue)) { | |
| Write-Host "Application does not exist, creating" | |
| New-Item $sitePath -PhysicalPath $(Resolve-Path .) -Type Application | |
| } else { | |
| Write-Host "Application exists. Complete" | |
| } | |
| Set-ItemProperty -Path "$sitePath" -Name "ApplicationPool" -Value "$applicationPoolName" | |
| Set-WebConfigurationProperty ` | |
| -Filter /system.WebServer/security/authentication/windowsAuthentication ` | |
| -Name enabled ` | |
| -Value $true ` | |
| -Location "$websiteName" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment