Note: This tip requires PowerShell 3.0 or above.
In an earlier tip, we looked at how we can retrieve the redirected URL using a .NET class. In today’s tip, we will look at how we can simplify that process using an in-built PowerShell 3.0 cmdlet – Invoke-WebRequest.
$uri = 'http://go.microsoft.com/fwlink/?LinkID=210601'
$request = Invoke-WebRequest -Uri $uri -MaximumRedirection 0 -ErrorAction Ignore
if($request.StatusDescription -eq 'found')
{
$request.Headers.Location
}
This is it. Much simpler than the earlier approach!


Pingback: Microsoft Most Valuable Professional (MVP) – Best Posts of the Week around Windows Server, Exchange, SystemCenter and more – #14 - TechCenter - Blog - TechCenter – Dell Community
Pingback: Microsoft Most Valuable Professional (MVP) – Best Posts of the Week around Windows Server, Exchange, SystemCenter and more – #14 - Dell TechCenter - TechCenter - Dell Community