Posting to Slack from Powershell

addnewapp

In the olden days twitter was a great way of reporting build statuses using a simple commandline.  These days it seems twitter is more the domain of plutocrats and the bots who love them.  I was sad when the twitter api was restricted, but rejoice, Slack is here!

Slack has become a very popular information hub for teams.  Because of Slack’s simple rest api it’s simple to report to a channel.

1. Create a “slack application”

addnewapp

Use this Url : https://api.slack.com/apps to go to the apps screen

addnewapp

2. Enable Webhooks

3. Copy the “Webhook Url”

4. Use this code in your powershell script…

$postSlackMessage = ‘{“text”:”hello world!'”}’
Invoke-RestMethod -Method Post -Uri yourwebhookurl -Body $postSlackMessage

 

mobileman has written 1 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>