Re: #PSTip Retrieve a redirected URL – PowerShell 3.0 way! - http://www.powershellmagazine.com/2013...
Feb 17, 2014
from
"Very nice. You should definitely change the if() test though: what you really want to check for is whether it's .StatusCode is a 3xx Redirect code, because "Found" isn't the only one that this would work for (at a minimum 303, 302, 304, I think). I'd just go for:
if($request.StatusCode -ge 300 -and $request.StatusCode -lt 400) {
$request.Headers.Location
}"
- Joel Bennett