Created
November 4, 2013 10:32
-
-
Save jamesantrobus/7300788 to your computer and use it in GitHub Desktop.
Bootstrap IIS with PowerShell
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
| Set-ExecutionPolicy RemoteSigned | |
| Import-Module WebAdministration | |
| Function bootstrap($siteName, $hostHeader, $sitePath, $pipelineMode) | |
| { | |
| $site = Get-WebSite | where { $_.Name -eq $siteName } | |
| if($site -eq $null) | |
| { | |
| echo "Creating site: $siteName" | |
| $appPool = New-WebAppPool -Name $siteName -Force | |
| $appPool | Set-ItemProperty -Name "managedPipelineMode" -Value $pipelineMode | |
| $absoluteSitePath = Resolve-Path $sitePath | |
| New-Website -Name $siteName -Port 80 -PhysicalPath $absoluteSitePath | |
| -ApplicationPool $siteName -HostHeader $hostHeader | |
| "127.0.0.1" + "`t`t" + $hostHeader | Out-File -encoding ASCII | |
| -append "C:\Windows\System32\drivers\etc\hosts" | |
| } | |
| } | |
| bootstrap "Site1" "site1.dev" "Solution\Site1" Integrated | |
| bootstrap "Site2" "site2.dev" "Solution\Site2" Classic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More here: http://blog.antrob.us/bootstrapping-iis-with-powershell/