OpsaC - Operating as PowerShell code
published: November 29, 2020 author: Tinu tags: PowerShell categories: PowerShell-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
Create a Channel in your MS Teams.
Add a Webhook for the Teams Channel.
$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