Microsoft Teams has a lot of cool features. This article will show you how to write a simple PowerShell bot that will post messages to a Teams channel.
Configure the WebHook in MS Teams
- Open the MS Teams Channel you want to add the bot to
- Click Connectors
- Click the Configure button by the Incoming WebHook option
- Give your WebHook a name...such and such Bot and you can upload an image if you want. Scroll down and click Create
- On the create screen you will see a URL. Copy this URL and save it somewhere you will need it in your PowerShell Script.
PowerShell Script
Sample PowerShell Script Below.
The script will run a simple SELECT statement on a DB and will Send a WebRequest to the URL you setup in Teams. The Bot will post a message to the channel you configured for the Incoming WebHook above.
If you do not want to mess with the Card Format then you can just post a simple message like this.
You can update the SQL Statement to pull data and display it in whatever channel.
0 comments:
Post a Comment