Send a Notification to Microsoft Teams via PowerShell
If you're not interested in all the words below, you can jump straight to the script here - github.com/mikeconjoice/Scripts
Having recently moved internally, to Microsoft Teams from Slack, we needed to adapt our scripts and monitoring solutions to send our alerts to our new endpoint.
I've created the following small PowerShell function to do all the payload compliation in the background to reduce the work required on your side to just the one simple command!
Send-toTeams
Before using the function, you'll need to create a webhook connector in the Microsoft Teams channel as follows.
Select the required channel and go to the Connectors option
Click Configure on the Incoming Webhook connector
Give the Webhook a name (and an optional image), and click Create
Copy the URL created to the clipboard and click Done
The URL will be outputted in the following format (which I have stored in the
$channel
variable here)Run the function with the required paramaters (-webhook, and -text) as described in the script
Check your Microsoft Teams channel and all being well you should see your message!
The code is listed below aswell as being available on my GitHub repo - github.com/mikeconjoice/Scripts