Public/New-TeamsChannelCard.ps1

Function New-TeamsChannelCard {
        <#
        .SYNOPSIS
        Sends a new teams card to the listed teams channel Webhook.
 
        .DESCRIPTION
        Creates a passphrase or password based on a large english word dictionary.
        It will fall back to pure random generation if dictionary is unreachable.
 
        .PARAMETER Message
        The message to be sent in the card.
         
        .PARAMETER WebhookUri
        The webhook uri.
         
        .EXAMPLE
        PS> New-TeamsChannelCard -Message <string> -WebhookUri
 
        .LINK
        https://github.com/nouselesstech/PowerShellHelpers
    #>


    param(
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [String]$Message,

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [String]$WebHookUri
    )

    try { 
        ## Form the WebHook Request
        $Headers = @{
            'Content-Type' = 'application/json'
        }

        $Body = @{
            'text' = $Message
        }

        ## Send the Request
        Invoke-WebRequest  `
            -Method POST `
            -Headers $Headers `
            -Body ($Body | ConvertTo-Json -Depth 100) `
            -Uri $WebHookUri | Out-Null

    } catch {
        throw "Could not send teams channel message. `r`n $_"
    }
}