Skip to content

Instantly share code, notes, and snippets.

@NickJosevski
Created August 22, 2012 12:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickJosevski/3425309 to your computer and use it in GitHub Desktop.
Save NickJosevski/3425309 to your computer and use it in GitHub Desktop.
Multiple IIS site creation, via PowerShell
Write-Host "Remember to run in an x86 Powershell"
Import-Module WebAdministration
$start_dir = Get-Location
CD IIS:\
New-Item AppPools\test.pool
Set-ItemProperty IIS:\AppPools\test.pool -name "enable32BitAppOnWin64" -Value "true"
Set-ItemProperty IIS:\AppPools\test.pool -name "managedRuntimeVersion" -Value "v4.0"
$sitesToCreate = 2
$path = "C:\dev\project-x\App.Web"
$appPool = "test.pool"
while ($sitesToCreate -gt 0)
{
$siteName = "s" + $sitesToCreate + ".site.local"
$siteWithIISPrefix = "IIS:\Sites\" + $siteName
Write-Host "Creating: " $siteName
$site = New-Item $siteWithIISPrefix -bindings @{protocol="http";bindingInformation="*:80:" + $siteName } -physicalPath $path
Set-ItemProperty IIS:\Sites\$siteName -name applicationPool -value $appPool
$sitesToCreate--
}
Write-Host "done"
CD $start_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment