Which Notifications does “Lola” subscribe to?


Recently I ran into an issue where I needed to enumerate the SCOM subscriptions a user subscribes to.  The management group in question has close to 250 subscriptions, and over 60 subscribers.  When someone (let’s call her “Lola”) leaves the company, it is now cumbersome to check which subscriptions should be re-configured for a new subscriber. A quick search on-line did not yield any results so I thought I would tackle it. 

Clearly this should be possible to do with PowerShell, and sure enough there are System Center 2012 Operations Manager commands which deal with notifications.  Running the command:

image

Yields a list of all the Operations Manager commands, including these 3 dealing with notifications:

image

The command we are looking for is Get-SCOMNotificationSubscription.  We can get help for the command with the aid of the Get-Help command, but there seems to be no built-in method to extract just the subscribers.

Making a call to the function is useful, in that it lets us see the structure and content of the data returned:

image

 

However, if I want to see all the subscriptions which have “Lola” as a recipient, the command by itself is not very useful.  I tried using some “where-object” filters, without success.  Not only does it not work, it does not fail with an error message either:

image

The “ToRecipients” field looked like a string containing the list of recipients, but clearly that can’t be right if I can’t use string comparison operators such as “-Like”, “-Contains” and “-Matches”.  Then I remembered that I can see the data type for the “ToRecipients” by using the “Get-Member” command in PowerShell:

image

As it turns out “Get-Member” is our friend.  The output above shows me that the “ToRecipients” property field is an IList Collection, which can be iterated through using one of the most useful PowerShell constructs: “foreach.”  So I put together a simple script:

1 import-module operationsmanager 2 $nameToFind = "Lola" 3 $subscriptions = get-scomnotificationsubscription 4 foreach ($s in $subscriptions){ 5 foreach ($r in $s.ToRecipients){ 6 if ($r.Name -eq $nameToFind){ 7 $s.DisplayName 8 } 9 } 10 }

 

When I run the script, I get  a list of all subscriptions that “Lola” subscribes to:

image

 

One final item is, how do I know what to put in the script variable above called “$nameToFind”?  Easy.  In the Administration workspace of the Operations Manager administration console, navigate to Subscribers.  Find the subscriber you are interested in, and open up its properties.  The name to use in the script is the text in the Subscriber Name field:

image

 

Now we can easily obtain a list of subscriptions we need to modify when someone leaves the company or changes roles within the organization.

Comments (0)

Skip to main content