Skip to content

Instantly share code, notes, and snippets.

@PrateekKumarSingh
Created October 7, 2018 15:18
Show Gist options
  • Save PrateekKumarSingh/7831b2ef0999671168e8ba1b71b31aa0 to your computer and use it in GitHub Desktop.
Save PrateekKumarSingh/7831b2ef0999671168e8ba1b71b31aa0 to your computer and use it in GitHub Desktop.
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