#OpsMgr: Extract notification information

One of the areas of OpsMgr that often have the biggest impact on others is the notifications and many customers create a large number of notification subscriptions, which sometimes makes it hard to manage.

I created this PowerShell script to help a customer to extract notification information, covering channels, subscribers and subscriptions. The output of the script is an HTML file saved to the highlighted location

############################################################################
#
#   SCOM-NotificationConfigurationReport-htmlout.ps1
#
#   Script by: Vanessa Bruwer
#
#    This script retrieves all notification configurations and outputs as HTML file.
#
############################################################################

# Variables

$ReportDate = Get-Date -format “yyyy-M-dd”

$rnd = Get-Random -minimum 1 -maximum 1000
$ReportLocation = “C:\Temp”
$ReportName = “$ReportDate-$rnd-SCOM-NotificationConfiguration.html”
$SavetoFile = “$ReportLocation\$ReportName”

# there should be no need to update the script beyond this point

# Delete any previous versions of the report for in case

If (Test-Path $SavetoFile){
     Remove-Item $SavetoFile
}

# Open the content
$body = “

Notification Configuration

# Connect to OperationsManager

Import-Module OperationsManager

$MGName = (get-scommanagementgroup).Name

# Get Channels

$body += “


$body += “

$Channels = Get-SCOMNotificationChannel

foreach ($Channel in $Channels)
{

$ChannelName = $Channel.DisplayName
$ChannelType = $Channel.ChannelType

#Write-Host $ChannelName, $ChannelType

$body += “

}

$body += “

Channels
Channel Display Name Type
$ChannelName $ChannelType

$body += “

# Get Subscribers

$body += “


$body += “

$Subscribers = Get-SCOMNotificationSubscriber

foreach ($subscriber in $Subscribers)
{
$Subscribername = $subscriber.Name

$subscriberaddress = ($subscriber.devices).Name

#Write-Host $Subscribername, $subscriberaddress

$body += “

}

$body += “

Subscribers
Display Name Address Name
$Subscribername $subscriberaddress


$body += “

# Get Subscriptions

$body += “


$body += “

$subscriptions = Get-SCOMNotificationSubscription

foreach ($subscription in $subscriptions)
{

$subname = $subscription.DisplayName
$subdescription = $subscription.Description
$subEnabled = $subscription.Enabled
$subrecipients = ($subscription.ToRecipients).Name

#Write-Host $subname, $subdescription, $subEnabled, $subrecipients

$body += “


}

$body += “

Subscriptions
Display Name Description Enabled Recipients
$subname $subdescription $subEnabled $subrecipients

$body += “

$body >> $SavetoFile

This is a sample of what the output looks like from my lab environment:

notifications

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s