Resolve-Url.ps1

function Resolve-Url
{
  <#
      .SYNOPSIS
      Short Description
      .DESCRIPTION
      Detailed Description
      .EXAMPLE
      Resolve-Url
      explains how to use the command
      can be multiple lines
      .EXAMPLE
      Resolve-Url
      another example
      can have as many examples as you like
  #>

  [CmdletBinding()]
  param
  (
    [Parameter(Mandatory)]
    [string]
    $url
  )
  
  $request = [System.Net.WebRequest]::Create($url)
  $request.AllowAutoRedirect=$false
  $response = $request.GetResponse()
  $url = $response.GetResponseHeader("Location")
  $response.Close()
  $response.Dispose()
  
  return $url
}