I needed something that could take pipeline input (objects passed from another script) and handle a variety of shortening services and was unable to find anything that met those requirements. Get-ShortenedURL is a PowerShell function that uses .Net to parse out the redirect URL (or more precisely the URI) and return it. Errors aren't really handled in a useful way, so you may want to add a "Write-Verbose" statement if you are interested in error handling.
Get-ShortenedURL Function
There are serious OPSEC concerns with using this method when dealing with malware or targeted attacks. The script is going to leave a record that it resolved the URL. There are services that can help with that and most shortening sites have an API which exposes the long URL. However, this can be used in a pinch to prevent being sent to a classic music video or to resolve bulk addresses.
-Chris
No comments:
Post a Comment