function Test-WebBinding { <# .SYNOPSIS Test if the given web binding exists on the site #> [CmdletBinding()] [OutputType([System.Boolean])] Param( [Parameter(Mandatory = $true)] [string]$website, [Parameter(Mandatory = $true)] [string]$url, [Parameter(Mandatory = $false)] [switch]$ssl ) $logLead = (Get-LogLeadName) $mgr = New-Object Microsoft.Web.Administration.ServerManager [string]$hostHeader = [string]::Empty if ($ssl) { $hostHeader = ("*:443:{0}" -f $url) } else { $hostHeader = ("*:80:{0}" -f $url) } if ($null -eq $mgr.Sites[$website]) { Write-Host ("$logLead : Website {0} does not exist" -f $website) return $false } else { foreach ($webBinding in $mgr.Sites[$website].Bindings.bindingInformation) { if ($webBinding -eq $hostHeader) { return $true } } return $false # binding not found } }