New-ShortURL.psm1

<#
.Synopsis
   Turns a full url into a short url
.DESCRIPTION
   The one and only Powershell short URL generator. This is using an API which is limited to 100 calls per minute. Allows you to turn a full url into a short url in a jiffy.
.Parameter FullURL
 Is expecting a string with the complete URL so for example https://adam-bacon.netlify.app/misionimpossible/ is a complete URL so I need to enter everything that would be displayed in the browser URL for this module to work
.EXAMPLE
   New-ShortURL -FullURL "https://c.tenor.com/BC-pwUamRsUAAAAM/tiny-small.gif"
.EXAMPLE
   New-ShortURL -FullURL "https://docs.microsoft.com/en-us/powershell/scripting/developer/cmdlet/validatepattern-attribute-declaration?view=powershell-7.2"
.NOTES
   Super easy way to generate short urls
.COMPONENT
   The component this cmdlet belongs to the community so use it wisely. This is based on the API that https://hideuri.com/ offers.
.ROLE
   The role this cmdlet belongs to you, so please do not breach the 100 calls per minute.
.FUNCTIONALITY
   The functionality that best describes this cmdlet is that it is the quickest way to get a short url using an API
#>


Function New-ShortURL {
    [CmdletBinding()]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,Position=0)]
        [ValidatePattern("^http://*.*|^https://*.*")]
           [String]$FullURL
    )
 Begin
    {
    Add-Type -AssemblyName System.Web
    }
    Process
    {
    foreach ($URL in $FullURL)
    {
    Write-Verbose -Message "The original url is $URL"
    $encodedURL = [System.Web.HttpUtility]::UrlEncode($URL)
    Write-Verbose -Message "The encoded url is $encodedURL"
    try
    {
    Invoke-RestMethod -Method Post -Uri "https://hideuri.com/api/v1/shorten" -Body "url=$encodedURL" 
    }
    catch
    {
        Write-Warning -Message "$encodedURL : $_"
    }       
    }
    }
    End
    {
    Write-Verbose "Script finished, thank you for using it"
    }

}