Push notifications to our mobile devices are something we’ve all become used to and expect from modern applications. But sending push notifications from our scripts is not as easy as sending emails. One system that fills that gap is Pushover. They provide a mobile app for iOS and Android that costs $5. After purchasing it you can send 7500 notifications per month for free, which is pretty reasonable.
The Pushover setup is pretty simple. After purchasing the app and establishing an account you can login to their dashboard to configure your account. Here you have access to your user token which works like your address. There’s all 3 configurable areas.
You can edit your devices that are running the Pushover app, disable a device, and see message stats for each device.
A Pushover Application functions like a message queue. Messages are sent to it and then distributed to recipients. When you receive a message it help you organize the notifications. You can upload an image that will be used as an icon on your device. From here you get the application token that you’ll need later.
A delivery group makes it easier to send notifications a group of people without having to modify your app or script later to add or remove user tokens. You add all the user tokens here and then send messsages to the single group token.
Sending Pushover Notifications from Powershell
Now that Pushover is setup you can start sending notifications from Powershell. Keep in mind the Pushover API is a very simple REST service so you can easily send from .NET or most any other language.
The script below is a simple way to push notifications to your device in real time. There are some Powershell Modules available, but they depend on Powershell 3.0 and I needed something that would work in Powershell 2.0 as well. A few highlights of this script.
I’m setting the Network Credentials on the WebClient to use the account running the script. This allows the POST to authenticate through my Web Proxy. If you don’t you’ll get a 401 error.
In my function I’m accepting an optional Priority parameter. Pushover supports the concept of Priority and will color the message red in the device. Using the Emergency Priority requires that the notification be acknowledged in the app or it will continue to alert on your device.
Pushover Notifications from Powershell