Created
October 7, 2018 15:18
-
-
Save PrateekKumarSingh/7831b2ef0999671168e8ba1b71b31aa0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Function Get-ShortURL | |
{ | |
[cmdletbinding()] | |
Param( | |
[Parameter(Mandatory=$True, ValueFromPipeline = $true)][string] $URL | |
) | |
Write-Verbose "Creating Short URL for $URL" | |
Invoke-RestMethod -Uri "https://www.googleapis.com/urlshortener/v1/url?key=AIzaSyDne5JQP_6F0aBsnz9RcItd3zeO1v6J734" ` | |
-Body $(''| Select-object @{n='longUrl';e={$URL}}|convertto-json) ` | |
-ContentType 'application/json' ` | |
-Method Post | ForEach-Object ID | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment