Sending Notifications to Teams using PowerShell

I thought that as so many of us are now using teams, why not send more information to a channel with results from automated PowerShell scripts.

We can do this via a webhook.

So lets setup a webhook on the Teams Channel.  We’ll need to do this via a connector.

Open the Channel and click the More Options button (which appears as three dots at the top right of the window) and Select Connectors.


Scroll down to Incoming Webhook and click the Add button.


Give the connector a name and image of your choosing and finally click Create.


A new unique URI is automatically generated. Copy this URI string to your clipboard.


Note: These details are available if you lose the url in the future.  Select the Connector and then click the Manage button to you can copy the URI string again.

Now we just want some PowerShell code to insert into the webhook, so this needs to be in JSON format.

This worked great.


But, I’d like to add more details to the notifications, like script identification, errors, etc that the scripts encountered. Message cards looked good, so I decided to try a basic message card.

Message cards can do a lot more than notification too. If you’re interested you can check out more about message cards in the references below.


I personally find this format is much better as a Teams notification as it could contain potentially a lot of information from scripts.


Message Cards