Skip to content

Instantly share code, notes, and snippets.

@chrisbrownie
Created November 16, 2016 05:45
Show Gist options
  • Save chrisbrownie/34df65a7c93ff744b7502ef2df63f32d to your computer and use it in GitHub Desktop.
Save chrisbrownie/34df65a7c93ff744b7502ef2df63f32d to your computer and use it in GitHub Desktop.
Evaluates redirects being returned by one or more URLs. Good for troubleshooting load balancers.
$urls = @(
"http://mysite.com",
"https://mysite.com.au/"
)
$tries = 100
foreach ($url in $urls) {
$targets = @()
1..$tries | % {
$x = Invoke-WebRequest $url -MaximumRedirection 0 -ErrorAction ignore -Verbose:$false
#$x.Headers.Location
$targets = $targets + $x.Headers.Location
}
"`nResults for target $url`:"
$targets | group | Format-List Name,Count
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment