Private/check_url.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# Returns nothing if url is valid, error otherwise function check_url( [string] $Url, [int]$Timeout, $ExcludeType='text/html' ) { if (!(is_url $Url)) { return "URL syntax is invalid" } try { $response = request $url $Timeout if ($response.ContentType -like "*${ExcludeType}*") { return "Bad content type '$ExcludeType'" } } catch { return "Can't validate URL`n$_" } } |