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:

  1. Create the PowerShell script which sends the OM2012 Alerts as Windows Phone Push Notifications.
  2. Create the Command Channel
  3. Create the Subscriber
  4. Create the Subscription
    1. Add the Subscribers
    2. 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 http://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 = "http://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.

image

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

image

Step 3. Create the Subscriber

Right click "Subscribers" and choose "New Subscriber"

image

Enter a easily to identify Subscriber name, like Windows Phone Push Notifications.

image

Configure the Schedule.

image

Enter a non-existing address

image

Configure the Channel

image

Click Next, click Finish

image

image

Step 4. Create the Subscription

We now need to create a new subscription. Right-click on "Subscriptions" and choose New Subscription.

image

Enter the Subscription Notification fields.

image

Click Next and Configure the Criteria.

In this test we will configure each alert with a Resolution State of New.

image

Click Next and add the previously created Subscriber

image

Click Next and add previously created Channel.

image

 

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.

WPPushNotifications 

image

Have fun configuring Windows Phone Push Notifications!