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 -

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!


Before using the function, you'll need to create a webhook connector in the Microsoft Teams channel as follows.

  1. Select the required channel and go to the Connectors option

  2. Click Configure on the Incoming Webhook connector

  3. Give the Webhook a name (and an optional image), and click Create

  4. Copy the URL created to the clipboard and click Done

  5. The URL will be outputted in the following format (which I have stored in the $channel variable here)

  6. Run the function with the required paramaters (-webhook, and -text) as described in the script

  7. 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 -