# Create Web Request Object
$request = [System.Net.WebRequest]::Create($url)
# Make it think we are using Edge on Windows 10. Required for some shorteners.
$request.UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
# Get the expanded URL
$request.GetResponse().ResponseUri.AbsoluteUri
This command will query a shortened URL and return the fully expanded URL. It has been tested with fb.me, bit.ly, zpr.io, aka.ms, buff.ly, t.co, ow.ly, tinyurl.com, & rviv.ly to name just a few. If you find any it doesn’t work with please let me know in the comments below.
PS C:\> $url = 'https://bit.ly/2KyctK3' >> $request = [System.Net.WebRequest]::Create($url) >> $request.UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246' >> $request.GetResponse().ResponseUri.AbsoluteUri https://www.dowst.dev/