PowerShell for Non-Noobs: Tracking 302’s

There are times I need to see what hops a URL takes along the way from what I type to what it shows in the address bar.  From a GUI, I just fire up Fiddler or HTTPWatch.  If I am trying to automate it, that's a different story.

PS> $url ='http://microsoft.com';

PS> $req = [system.net.webrequest]::create($url);

PS> $req.AllowAutoRedirect = $false;

PS> $res = $req.GetResponse();

PS> $res.Headers.Get('location');

PS> $res.Close();

Comments (0)

Skip to main content