Created
December 14, 2015 17:55
-
-
Save dkittell/d11d6bf7ac03d5c52355 to your computer and use it in GitHub Desktop.
Create TinyURL within PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear | |
Function Get-TinyURL { | |
#PowerShell - Get-TinyURL API Call | |
param ( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true)] | |
[String] | |
$sHTTPLink | |
) | |
if ($sHTTPLink.StartsWith("http://") -eq $true -or $sHTTPLink.StartsWith("https://") -eq $true) | |
{ | |
if ($WebClient -eq $null) {$Global:WebClient=new-object System.Net.WebClient } | |
$webClient.DownloadString("http://tinyurl.com/api-create.php?url=" + [System.Web.HttpUtility]::UrlEncode($sHTTPLink)) | |
} | |
else | |
{ | |
Write-Output "Bad Link, please include http:// or https://" | |
} | |
} | |
Get-TinyURL "http://google.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment