PowerShell

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

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.

This post was last modified on October 4, 2018 20:01

Przemyslaw Klys

System Architect with over 14 years of experience in the IT field. Skilled, among others, in Active Directory, Microsoft Exchange and Office 365. Profoundly interested in PowerShell. Software geek.

Share
Published by
Przemyslaw Klys

Recent Posts

Upgrade Azure Active Directory Connect fails with unexpected error

Today, I made the decision to upgrade my test environment and update the version of…

1 week ago

Mastering Active Directory Hygiene: Automating Stale Computer Cleanup with CleanupMonster

Have you ever looked at your Active Directory and wondered, "Why do I still have…

4 months ago

Active Directory Replication Summary to your Email or Microsoft Teams

Active Directory replication is a critical process that ensures the consistent and up-to-date state of…

8 months ago

Syncing Global Address List (GAL) to personal contacts and between Office 365 tenants with PowerShell

Hey there! Today, I wanted to introduce you to one of the small but excellent…

1 year ago

Active Directory Health Check using Microsoft Entra Connect Health Service

Active Directory (AD) is crucial in managing identities and resources within an organization. Ensuring its…

1 year ago

Seamless HTML Report Creation: Harness the Power of Markdown with PSWriteHTML PowerShell Module

In today's digital age, the ability to create compelling and informative HTML reports and documents…

1 year ago