次の方法で共有


OpsMgr 2007:How to enable Notification Subscription using Powershell

Recently i had come accross a request where we wanted to enable/disable notifitication using powershell. Although this really should be a straight forward process really couldnot find a real simple script to demo out an example, so i decided to write the below extract.

This particular script scans what all Notification Subscriptions are disabled and enables them

=============================
$rootMS="<RMSSERVERNAME>"
Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin;
Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin;
set-location $rootMS -ErrorVariable errSnapin;
$subss = Get-NotificationSubscription | where {$_.ENABLED -ne "TRUE" }
foreach ($sub1 in $subss)
{
if ($sub1 -ne $null)
{
enable-NotificationSubscription $sub1
}
}
=============================

One of key thing which i realised was get-NotificationSubscription would actually return Null Object if none of the subscription met the criteria.So an additional check was put in place to check if the object was NULL before we enable the subscription using the enable-NotificationSubscription option.

As such, Microsoft makes no warranties or guarantee's regarding the applicability of this script, nor does Microsoft support the use of this tool in any way. This is just one of those 'use at your own risk' type of things that hopefully you'll find helpful.

Hope you find this post helpful

Jeevan Bisht | Manageability Technical Lead

Comments

  • Anonymous
    January 01, 2003
    Can you give an example of enabling and disabling a custom Notification Subscription in SCOM 2007 R2 using this powershell script? Let's say the Subscription is called "DBA Subscription" and is a custom subscription, not the Notification Subscription in general.