Resolving URLs

by May 21, 2013

Sometimes you may stumble across URLs like this one:

http://go.microsoft.com/fwlink/?LinkID=13517

As it turns out, these are just "pointers" to the real web address. In PowerShell 3.0, the new cmdlet Invoke-WebRequest can resolve these URLs and return the real address that it points to:

$URLRaw = 'http://go.microsoft.com/fwlink/?LinkID=135173'
(Invoke-WebRequest -Uri $URLRaw -MaximumRedirection 0 -ErrorAction Ignore).Headers.Location

Twitter This Tip! ReTweet this Tip!