Tinus EngOps Wiki


OpsaC - Operating as PowerShell code



PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View Tinus IT Wiki

View my Photo Website


tags: PowerShell categories: PowerShell-Module

Table of Contents

PSTeams Module

PSTeams is a PowerShell Module working on Windows / Linux and Mac. It allows sending notifications to Microsoft Teams via WebHook Notifications.

Install-Module -Name PSTeams

Prepare MS Teams

Create a Channel in your MS Teams.
Add a Webhook for the Teams Channel.

Send notifications to MS Teams

$TeamsID = 'WebhookURL'

$Fact1 = New-TeamsFact -Name 'OS' -Value "**$($PSVersionTable.OS)**"
$Fact2 = New-TeamsFact -Name 'User' -Value "**$($env:Username)**"
$Fact3 = New-TeamsFact -Name 'PS Version' -Value "**$($PSVersionTable.PSVersion)**"
$Fact4 = New-TeamsFact -Name 'PS Edition' -Value "**$($PSVersionTable.PSEdition)**"

$CurrentDate = Get-Date

$Section = New-TeamsSection `
    -ActivityTitle "**Notification XYZ**" `
    -ActivitySubtitle "@PSTeams - $CurrentDate" `
    -ActivityImage Add `
    -ActivityText "This message proves PSTeams Pester test passed properly." `
    -ActivityDetails $Fact1, $Fact2, $Fact3, $Fact4

Send-TeamsMessage `
    -URI $TeamsID `
    -MessageTitle 'PSTeams - Test' `
    -MessageText "This text won't show up" `
    -Color DodgerBlue `
    -Sections $Section

See also

EvotecIT PSTeams

[ Top ] [ Blog ]