Skip to content

Instantly share code, notes, and snippets.

@rchaganti
Created May 28, 2014 13:48
Show Gist options
  • Save rchaganti/c30375210710d5bd3c6a to your computer and use it in GitHub Desktop.
Save rchaganti/c30375210710d5bd3c6a to your computer and use it in GitHub Desktop.
Test a URL!
Function Test-Url {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[String] $Url
)
Process {
if ([system.uri]::IsWellFormedUriString($Url,[System.UriKind]::Absolute)) {
$true
} else {
$false
}
}
}
#Here is how we use it
$doc = Invoke-WebRequest -Uri 'https://www.python.org/downloads'
foreach ($href in ($doc.links.href -ne '')) {
if (Test-Url -Url $href) {
$href
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment