This is one widely known “inconvenience” with working with Powershell to manage our subscriptions in a big SCOM environment. Consider the following widely common scenario:

We have a SCOM environment with a fairly large number of subscriptions. We have a planned maintenance scheduled, and so we plan to disable all our subscriptions so that the support teams aren’t bothered with unnecessary alerts. There is a simple quick way of doing this:

Import-Module OperationsManager

Get-SCOMNotificationSubscription | Disable-SCOMNotificationSubscription

This will disable all our subscriptions and stop sending notifications out. This is simple enough. The issue lies with enabling them back. The catch here is when we enable the subscription using Powershell, we start getting all the notifications that were “cached” during the time of the maintenance mode, and our support teams are bombarded with tens or even hundreds of such spam notifications. This is because when we enable the subscriptions with Powershell, it enabled it using the default option of “More messages”. Moreover, there is no apparent parameter/switch to change it to “Fewer messages”.

Get-SCOMNotificationSubscription | Enable-SCOMNotificationSubscription

If we are not familiar with these two options, here’s what they mean:

More Messages: This option means all the notifications that were cached since the subscription was disabled are forwarded to subscribers.

Fewer Messages: This option means only the notifications that are generated after the subscription was re-enabled are forwarded to the subscribers.

This discussion was actually happening a few days ago on the SCOM Community Gitter Lobby (make sure to join!), and Dimitry K. suggested an excellent workaround on this issue (Kudos, Dimitry!). There’s no parameter in the cmdlet to switch options but you can actually do this using a method. Here’s the code:

$sub = Get-SCOMNotificationSubscription | where {$_.displayname -like "SUBSCRIPTION_NAME"}

$sub.Enabled = $true

$sub.Update($true)

Note the last line - $sub.Update($true)

The value we pass to this method actually determines the option to choose more or fewer messages. If we choose Update($true), it is equivalent to fewer messages, and if we choose Update($false), it is equivalent to more messages in the GUI.