Skip to content

Instantly share code, notes, and snippets.

@jamesantrobus
Created November 4, 2013 10:32
Show Gist options
  • Save jamesantrobus/7300788 to your computer and use it in GitHub Desktop.
Save jamesantrobus/7300788 to your computer and use it in GitHub Desktop.
Bootstrap IIS with PowerShell
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
@jamesantrobus
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment