Instantly share code, notes, and snippets.

Embed
What would you like to do?
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