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 $_"
    }
}
# SIG # Begin signature block
# MIIDOAYJKoZIhvcNAQcCoIIDKTCCAyUCAQExDzANBglghkgBZQMEAgMFADCBmwYK
# KwYBBAGCNwIBBKCBjDCBiTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63
# JNLGKX7zUQIBAAIBAAIBAAIBAAIBADBRMA0GCWCGSAFlAwQCAwUABED89/MtIddW
# qMh9zfnSCVAaIF+ojC0wNuOB/zNIFjHnTLBqj4ZOZ7+4szgzPBS+klRYV+Eovrtr
# 3svMrtRoz1sxoIIBRTCCAUEwgeigAwIBAgIUJUrhIyYe0Ijmq8lkl4K8jyNrTDUw
# CgYIKoZIzj0EAwIwIDEeMBwGA1UEAwwVY29ubm9yQG5vdXNlbGVzcy50ZWNoMCAX
# DTI0MDUwNTA0MDUyOVoYDzIyMjIxMjIyMDAwMDAwWjAgMR4wHAYDVQQDDBVjb25u
# b3JAbm91c2VsZXN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