Powershell module for sending rich messages to Microsoft Teams through channel webhooks.
For basic operation simply clone or download the module to your local machine or module repo.
This module has a required parameter for the URI which is created when adding a webhook to a Microsoft Teams channel.
To enable a webhook on a channel:
- Open Microsoft Teams
- Create a new channel or select and existing
- Press the three dots '...' to open the settings
- Select 'Connectors'
- Once the screen loads, select 'Incoming Webhook' by pressing 'Configure'
- Enter a name and upload and image (if required)
When you select 'Create' the next screen will show a 'URI', make sure you save this somewhere for later use in your script
Add the module files to you module path and use:
Import-Module PSMicrosoftTeams
I have changed the images to be embedded in the script for simplicity and portability. These images are just Base64 encoded strings of the original included images
To replace the images use the command:
[convert]::ToBase64String((Get-Content .\warning.jpg -Encoding Byte))
Then copy the output string into the variables in the 'InlineImages' region.
To send an MS Teams notification from a script use the following format:
Send-TeamChannelMessage -messageType Information -messageTitle "Test Title" -messageBody "Test body" -activityTitle "test Activity" -URI "INSERT YOUR WEBHOOK URI HERE" -details @(@{ name = 'name1'; value = 'value1' }, @{ name = 'name2'; value = 'value2' }, @{ name = 'name3'; value = 'value3' }) -buttons @(@{ name = 'Google'; value = 'https://www.google.com' }, @{ name = 'IT Support Desk'; value = 'https://itsupportdesk.com' }, @{ name = 'PRTG'; value = 'https://prtg.com' })
See the module for a full parameter explanation.
For instructions on these examples plese see the 'EXAMPLES' sub-folder.
https://github.com/mhouston100/PSMicrosoftTeams
- Matthew Houston - Initial work -
See also the list of contributors who participated in this project.