Scroll Top
Evotec Services sp. z o.o., ul. Drozdów 6, Mikołów, 43-190, Poland

PSTeams – Send notifications to MS Teams from Mac / Linux or Windows

PSTeams - Cross-Platform

If you're new to this module it's very simple PowerShell module allowing to send notifications straight to Microsoft Teams channels. Full overview of this module is available on dedicated page for PSTeams. New release version 0.2 is small addition to PowerShell cross-platform modules allowing you to run it on Windows, Linux or Mac. This means from now on you can tell your scripts on Linux to send information straight to Microsoft Teams!

PSTeams Information
Please notice this article contains parts of information (still useful) and may not reflect all functionalities of this module. For download, source code and so on you should refer to the dedicated PSTeams module page. After reading this one… of course! It contains useful informationexamples and know-how. Without it… you may be lost!
How can I use it?

To use it on Windows / Linux or Mac simply run

Install-Module PSTeams
# Update-Module PSTeams
Useful links
Code is published on GitHub
Issues should be reported on GitHub
Code is published as a module on PowerShellGallery
Azure Pipelines / Pester Testing

I've actually used this release as a testing ground for Azure Pipelines (Azure DevOps) that allows for testing PowerShell modules on all 3 platforms (Windows / Linux and Mac) along with using Secret/Private Key (Teams Channel ID). I've actually written simple Pester for this scenario that sends a message to my testing Microsoft Teams channel with information when testing on each platform is done.  So when I commit new changes to GitHub I expect to get new notifications in Teams.

It actually sends a bit of information each time it does that. So below you can see Linux tests

Windows tests

And finally MacOS tests

This also shows how useful it can be for random scripts you run in your environment. You can simply add notification before/after with some specific information that you need such as script executed successfully, user was added to AD and so on. My current biggest use case for this is my PSWinReporting project that sends updates Live as they happen on Active Directory telling me that user was added or removed from group or that he changed his password.

So if you're into starting it up…

$TeamsID = 'YourCodeGoesHere'
$Button1 = New-TeamsButton -Name 'Visit English Evotec Website' -Link "https://evotec.xyz"

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

$CurrentDate = Get-Date

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

Send-TeamsMessage `
    -URI $TeamsID `
    -MessageTitle 'PSTeams - Pester Test' `
    -MessageText "This text won't show up" `
    -Color DodgerBlue `
    -Sections $Section
PSTeams Information
Please notice this article contains parts of information (still useful) and may not reflect all functionalities of this module. For download, source code and so on you should refer to the dedicated PSTeams module page. After reading this one… of course! It contains useful informationexamples and know-how. Without it… you may be lost!

This is the code responsible for what you see on Pester tests. So have fun. Make sure to check main PSTeams article for a full know-how.

Related Posts