Slack and PowerShell 2.0

I am personally in love with Slack. It is a great communication tool for a company or project or whatever you want it to be used for. And as a sysadmin using Slack as your notification channel for your various scripts that run is great instead of the good old email. You can use the integration services for Slack to for example post in a Slack channel about the status of a script if it either failed or succeeded.

It’s a great tool which I highly recommend you try out however on older systems you may have limitations to use the integration and the various options to connect from server to Slack. In my case this was when I encountered a product that required Windows PowerShell 2.0 and any other version of it would break the product. But on the server in question I still wanted to do notifications in Slack but the PowerShell available Slack modules were simply using a newer version of PowerShell (Atleast at the time of my researching this). However for every challenge there is a solution. I can program a bit in C# and made a simple to use command line-ish program that you can use to integrate with Slack if you are using a Windows PowerShell 2.0 restricted server.

The program is called Send-Slack and it has a few pieces of information needed to integrate with Slack. The most important one of the token. The token is used to function as a password for your integration. Second the channel on which you want to post a message this could be a notification channel of some sort. Then the script which is used to give the message a username which posted it which I use to input the various scripts and the names I gave to them. The last but not least the message it self.

Now for my purposes this was more then was needed and I never built in any kind of complex text handling or emojies or images into my notification design. So keep that in mind.

The general usage results as follows:

Send-Slack.exe /message |messagehere| /channel |slackchannelhere| /script |insertscriptnamehere| /token |webhooktokenurlhere|

The | character is one I use as a split character. To better handle between the different and often complex lines of text.

If you are finding yourself in a situation with .NET Framework 4.5.2 or newer but a strict requirement on using Windows PowerShell 2.0 and nothing else. Of course you should upgrade the product but in the meantime you can download the program and use it if you like. Maybe it will help you as much as it helped me.

Download Send-Slack

Leave a Comment