If I had to make a list of my favorite things on earth, two items near the top of the list would be Windows PowerShell and the iPhone. Being able to put those things together now is one of those game-changing experiences for me.
First, let me explain the problem at hand. I manage a lot of IT systems, and am generally on call 24x7 in the event that one of those systems goes down. For ages, I’ve constantly tried to come up with the best (and cheapest) way to be notified in the event of a critical failure, especially during night hours. Email notifications won’t meet this need obviously, because you’re not going to have an email notification wake you up in the middle of the night. SMS text messages get a little closer, but still don’t meet the needs of all scenarios, especially around varying priority levels. I had just about given up… until I discovered Prowl.
Prowl is an application for the iPhone, originally designed to supplement Growl, but now becoming an awesome application by itself. The basic purpose of Prowl is to receive push notifications of your desired events via Apple’s iPhone Push Notification Service. Prowl then sounds an alert, and these sounds can vary based on the priority for which you’ve set the alert, from low to emergency.
I had first started using Prowl as a Growl forwarder, and then signed up for Google Voice alert forwarding. Both of those setups were nice, but things really began to get exciting when I found out that I could send my own Prowl alerts using PowerShell (which allows for linking up pretty much anything on earth), and even allow others to send me alerts as well.
I’ve now setup my iPhone with a very loud and obnoxious alert that will trigger in the event that it receives an emergency alert from Prowl. This could be that a mission critical system is down, or that someone important is trying to reach me immediately. Prowl even allows you to set quiet hours for receiving notifications on your iPhone, and also allows you to set an emergency override.
So, what do you need to configure Prowl to send alerts to your iPhone with PowerShell? Well, obviously, you’d need:
1) An iPhone
2) Prowl
4) A Prowl.net DLL (this one isn’t required, but makes things *much* easier).
5) A PowerShell function to send your alerts (provided below).
Once you’ve configured Prowl on your iPhone and downloaded
the Prowl.dll, simply import the PowerShell function and then start sending:
function Send-Prowl
{ param($Description="Default Description", $priority=”Normal”)
[Reflection.Assembly]::LoadFile("C:\Prowl\Prowl.dll")
$prowlclientconfig = New-Object prowl.ProwlClientConfiguration
$prowlclientconfig.ApiKeychain ="set this to your Prowl API Keychain from
the Prowl website”
$prowlclientconfig.ApplicationName = "PowerProwl”
$prowlclient = New-Object prowl.ProwlClient($prowlclientconfig)
$prowlnotification = New-Object Prowl.ProwlNotification
$prowlnotification.Event = "PowerShellAlert”
$prowlnotification.Priority = $priority
$prowlnotification.Description = $description
$prowlclient.PostNotification($prowlnotification)
}
In the example provided, the only thing you have to change is your Prowl API keychain value (unique to your iPhone, and found on the Prowl website), and the file location for your Prowl DLL . Everything else can be modified as desired, but doesn’t have to be. Once you have the function setup, you can start incorporating Send-Prowl into various monitoring tasks, from scheduled tasks, OpsManager triggers, etc. - you could even have it tied to a home automation system to send you alerts when your front door opened.
It’s also a way to have your closest contacts reach you in the event of an emergency. Assuming they have PowerShell and the Prowl.dll, they can just contact you by using something like:
Send-Prowl -priority Emergency –description “Please call me ASAP! Water line just broke!!!”
By the way, before anyone critiques the sloppiness of the PowerShell script, this script is meant only as a quick-start example to show people how to use the DLL, as I didn’t find any example Prowl PowerShell code on the internet (the examples were in C#). You’ll want to customize it to your needs.
Happy Prowling!
Janssen