Windows Phone Push Notifications for your OpsMgr Alerts - Part 2
This is part 2 in a two blog post series about configuring Windows Phone Push Notifications for OpsMgr 2012. Please read blog post part 1 first, if you have not read this.
Disclamer: I’ve this only tested on OM2012 SP1 and you need PowerShell v3 to have the script working.
In this blog post we are going configure the Notification. These are the high-level steps to configure OM2012 Notifications:
- Create the PowerShell script which sends the OM2012 Alerts as Windows Phone Push Notifications.
- Create the Command Channel
- Create the Subscriber
- Create the Subscription
- Add the Subscribers
- Choose the Command Channel
Step 1. Create the PowerShell script which sends the OM2012 Alerts as Windows Phone Push Notifications.
We need to create a PowerShell script which sends the OM2012 Alerts as Windows Phone Push Notifications. We store this script on the Management Server in a location of your own choice.
In this example I store the WindowsPhonePushNotifications_v0.1.ps1 script in the C:\Scripts folder on the Management Server.
The script has three parameters which are show in the Windows Phone Push Notifications:
- Alert Name
- Alert Severity
- Alert Time Raised
#Requires -Version 3
#######################################################################################################################
# Using the Notify my Windows Phone API using PowerShell
# Author: Stefan Stranger
# Disclamer: This program source code is provided "AS IS" without warranty representation or condition of any kind
# either express or implied, including but not limited to conditions or other terms of merchantability and/or
# fitness for a particular purpose. The user assumes the entire risk as to the accuracy and the use of this
# program code.
# Date: 01-05-2012
# Name: NotifyMyWindowPhone_v0.1.ps1
# v0.01 - 01-05-2012 - Stefan Stranger - sstranger's initial release
# v0.02 - 01-07-2012 - Stefan Stranger - Added Notification Channel Subscriptions
########################################################################################################################
Param($alertname,$alertseverity,$alertTimeRaised)
# Enter your own API Key from https://www.nmwp7.com/user/apikeys
$apikey = "[enter here your api key]"
# Enter the name of the application the notification originates from.
$application = "OM2012"
# Enter The event that occured. Depending on your application, this might be a summary, subject or a brief explanation.
$event = "OM2012 Alert"
# The full body of the notification.
$description = @"
AlertName: $alertname
AlertSeverity: $alertseverity
AlertTimeRaised: $alertTimeRaised
"@
#You can enable the write-eventlog for logging purposes.
#write-eventlog -LogName Application -source MSIInstaller -EventId 999 -entrytype Information -Message $description
# An optional value representing the priority of the notification.
$priority = "-2"
# Specifies the responsetype you want. You can currently choose between JSON or XML (default)
$type = "json"
$uri = "https://notifymywindowsphone.com/publicapi/notify?event=$event&priority=$priority&application=$application&description=$description&apikey=$apikey&type=$type"
Invoke-WebRequest -Uri $uri
Step 2. Create the Command Channel
Go to Administration -> Notifications -> Channels and choose New Channel.
Give your Channel a name. (example Windows Phone Push Notifications)
Enter the Command Notification Channel Settings.
Full path of the command file:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe
Command line parameters:
C:\Scripts\WindowsPhonePushNotifications_v0.1.ps1 '$Data/Context/DataItem/AlertName$' '$Data/Context/DataItem/Severity$' '$Data/Context/DataItem/TimeRaisedLocal$'
Startup folder for the command line:
C:\Scripts
Step 3. Create the Subscriber
Right click "Subscribers" and choose "New Subscriber"
Enter a easily to identify Subscriber name, like Windows Phone Push Notifications.
Configure the Schedule.
Enter a non-existing address
Configure the Channel
Click Next, click Finish
Step 4. Create the Subscription
We now need to create a new subscription. Right-click on "Subscriptions" and choose New Subscription.
Enter the Subscription Notification fields.
Click Next and Configure the Criteria.
In this test we will configure each alert with a Resolution State of New.
Click Next and add the previously created Subscriber
Click Next and add previously created Channel.
Click Next and Finish.
Now we test our Command Channel with a test Alert Rule and watch our Windows Phone for the Push Notifications.
If everything is working as expected you will see the following Windows Phone Push Notifications.
Have fun configuring Windows Phone Push Notifications!