I currently use the below PowerShell script to shorten any URL via the Bitly V3 API. I am hoping someone can help to do the same thing using the Bitly V4 API.
function New-ShortURL {
param (
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)]
$URL
)
#https://app.bitly.com API
$OAuthToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$MyURL=Invoke-WebRequest -Uri https://api-ssl.bitly.com/v3/shorten -Body @{access_token=$OAuthToken;longURL=$URL} -Method Get
$MyURLjson = $MyURL.Content | convertfrom-json
$MyURLjson.data.url
}