[CmdletBinding()] param( [string]$SiteName = 'WscMvc', [string]$PoolName = 'WscMvc', [string]$PhysicalPath, [int]$Port = 8090 ) Import-Module WebAdministration if (-not $PhysicalPath) { $PhysicalPath = Split-Path -Parent $PSScriptRoot } if (-not (Test-Path "IIS:\AppPools\$PoolName")) { New-WebAppPool -Name $PoolName | Out-Null Set-ItemProperty "IIS:\AppPools\$PoolName" -Name managedRuntimeVersion -Value '' Set-ItemProperty "IIS:\AppPools\$PoolName" -Name enable32BitAppOnWin64 -Value $false Write-Output "Created app pool $PoolName (64-bit, no managed code)" } else { Write-Output "App pool $PoolName already exists" } if (-not (Test-Path "IIS:\Sites\$SiteName")) { New-Website -Name $SiteName -Port $Port -PhysicalPath $PhysicalPath -ApplicationPool $PoolName | Out-Null Write-Output "Created site $SiteName on port $Port -> $PhysicalPath" } else { Write-Output "Site $SiteName already exists" } Start-WebAppPool -Name $PoolName -ErrorAction SilentlyContinue Start-Website -Name $SiteName -ErrorAction SilentlyContinue Get-Website -Name $SiteName | Select-Object Name, State, PhysicalPath, ApplicationPool