June 16, 2009

TinyUrl and Powershell

TinyUrl is something that I assume most of you have used or at least heard about. Basically, it creates a short version of your long URL. It is available free to anyone and is best used for long query strings that probably will break in an email. I figured why not show how it can be created using POSh. An example is below:
#Create the function
function Gen-TinyUrl($url){
(new-object net.webclient).downloadString("http://tinyurl.com/api-create.php?url=$url")
}

#Call the function
$gen = Gen-TinyUrl -url http://joelangley.blogspot.com
$gen
The output being: http://tinyurl.com/lmusyc

How easy was that!

No comments:

Post a Comment