Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssougnez/7ce39b725602ff281beffac6d032c3fc to your computer and use it in GitHub Desktop.
Save ssougnez/7ce39b725602ff281beffac6d032c3fc to your computer and use it in GitHub Desktop.
Function CreateWebSite {
Param([string]$hostname, [string]$port, [string]$destination)
Begin {
Push-Location
}
Process {
$name = GetSiteName $hostname $port
Set-Location "IIS:\Sites\"
if ((Test-Path $name -PathType container) -eq $true) {
Warning "The IIS site already exists."
}
else {
$site = New-Item $name -bindings @{protocol = "http"; bindingInformation = $(":{0}:" -f $port) + $hostname} -PhysicalPath $destination
$site | Set-ItemProperty -Name "applicationPool" -Value $hostname
Success
}
}
End {
Pop-Location
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment