Add-SCOMNotificationSubscription

Adds a notification subscription.

Syntax

Add-SCOMNotificationSubscription [-Name] <String> [[-Criteria] <String>]
 [-BccSubscriber <NotificationRecipient[]>] [-CcSubscriber <NotificationRecipient[]>] -Channel <Object[]>
 [-ComputerName <String[]>] [-Credential <PSCredential>] [-Delay <TimeSpan>] [-Description <String>]
 [-Disabled] [-DisplayName <String>] [-OnlyOnResolutionChange] [-PollingInterval <TimeSpan>]
 [-SCSession <Connection[]>] -Subscriber <NotificationRecipient[]> [-Confirm] [-WhatIf] [<CommonParameters>]

Description

The Add-SCOMNotificationSubscription cmdlet adds a notification subscription in System Center 2016 - Operations Manager.

In this release there is no cmdlet support for scoping subscriptions based on a criteria, but you can achieve this result through Windows PowerShell by accessing the SCOM SDK directly.

Examples

Example 1: Add a notification subscription

PS C:\>$Subscriber = Get-SCOMNotificationSubscriber -Name "John Smith","Sarah Jones"
PS C:\> $Channel = Get-SCOMNotificationChannel -DisplayName "EmailChannel"
PS C:\> Add-SCOMNotificationSubscription -Name "NewSubscription1" -Subscriber $Subscriber -Channel $Channel
This example adds a new notification subscription for all alerts. The first command uses the Get-SCOMNotificationSubscriber cmdlet to get subscribers and stores the result in the $Subscriber variable. The second command uses the Get-SCOMNotificationChannel cmdlet to get the notification channel, and stores the result in the $Channel variable. The third command uses the Add-SCOMNotificationSubscription cmdlet with the Name , Subscriber , and Channel parameters.

Example 2: Add a notification subscription with conditions

PS C:\>$Subscriber = Get-SCOMNotificationSubscriber -Name "John Smith","Sarah Jones"
PS C:\> $Channel = Get-SCOMNotificationChannel -DisplayName "EmailChannel"
PS C:\> Add-SCOMNotificationSubscription -Name "NewSubscription2" -Subscriber $Subscriber -Channel $Channel -Delay "1:00:00" -Disabled
This example adds a new notification subscription for all alerts, but only notifies if conditions remain unchanged for 1 hour. The example creates the subscription in the disabled state. The first command uses the Get-SCOMNotificationSubscriber cmdlet to get subscribers and stores the result in the $Subscriber variable. The second command uses the Get-SCOMNotificationChannel cmdlet to get the notification channel, and stores the result in the $Channel variable. The third command uses the Add-SCOMNotificationSubscription cmdlet with the Name , Subscriber , and Channel parameters.

Example 3: Add a new subscription for instances of a specific class

PS C:\>$Subscriber = Get-SCOMNotificationSubscriber -Name "John Smith","Sarah Jones"
PS C:\> $Channel = Get-SCOMNotificationChannel -DisplayName "EmailChannel"
PS C:\> $Subscription = Add-SCOMNotificationSubscription -Name "NewSubscription3" -Subscriber $Subscriber -Channel $Channel
PS C:\> $HealthService = Get-SCOMClass -Name "Microsoft.SystemCenter.HealthService"
PS C:\> $Subscription.Configuration.MonitoringClassIds.Add( $HealthService.Id )
PS C:\> $Subscription.Update()
This example adds a new notification subscription for all alerts, then uses the Operations Manager SDK to scope the subscription to alerts raised by instances of the HealthService class. The first command uses the Get-SCOMNotificationSubscriber cmdlet to get subscribers and stores the result in the $Subscriber variable. The second command uses the Get-SCOMNotificationChannel cmdlet to get the notification channel, and stores the result in the $Channel variable. The third command uses the Add-SCOMNotificationSubscription cmdlet with the Name , Subscriber , and Channel parameters. The cmdlet stores the result in the $Subscription variable. The fourth command uses the Get-SCOMClass cmdlet and stores the result in the $HealthService variable. The fifth command uses the Add method with the ID of the $HealthService variable. The sixth command uses the Update method.

Example 4: Add a notification subscription by using the SDK

PS C:\>$Subscriber = Get-SCOMNotificationSubscriber -Name "John Smith","Sarah Jones"
PS C:\> $Channel = Get-SCOMNotificationChannel -DisplayName "EmailChannel"
PS C:\> $Subscription = Add-SCOMNotificationSubscription -Name "NewSubscription4" -Subscriber $Subscriber -Channel $Channel
PS C:\> $WindowsComputers = Get-SCOMGroup -DisplayName "All Windows Computers"
PS C:\> $Subscription.Configuration.MonitoringObjectGroupIds.Add( $WindowsComputers.Id )
PS C:\> $Subscription.Update()
This example adds a new notification subscription for all alerts, and then uses the Operations Manager SDK to scope the subscription to alerts raised by instances in the All Windows Computers group. The first command uses the Get-SCOMNotificationSubscriber cmdlet to get subscribers and stores the result in the $Subscriber variable. The second command uses the Get-SCOMNotificationChannel cmdlet to get the notification channel, and stores the result in the $Channel variable. The third command uses the Add-SCOMNotificationSubscription cmdlet with the Name , Subscriber , and Channel parameters. The cmdlet stores the result in the $Subscription variable. The fourth command uses the Get-SCOMGroup cmdlet to get the All Windows Computers group, and stores the result in the $WindowsComputers variable. The fifth command uses the Add method with the Id of the $WindowsComputers variable. The sixth command uses the Update method.

Example 5: Add a notification subscription for a specific monitor

PS C:\>$Subscriber = Get-SCOMNotificationSubscriber -Name "John Smith","Sarah Jones"
PS C:\> $Channel = Get-SCOMNotificationChannel -DisplayName "EmailChannel"
PS C:\> $Monitor = Get-SCOMMonitor -DisplayName "ContosoMonitor"
PS C:\> $Criteria = @"
>>
>>
>>
>>
>>ProblemId
>>
>>Equal
>>
>>$($monitor.Id)
>>
>>
>>
>>
>>
>>
>>Severity
>>
>>Equal
>>
>>2
>>
>>
>>
>>"@
PS C:\> Add-SCOMNotificationSubscription -Name "Subscription03" -Subscriber $Subscriber -Channel $Channel -Criteria $Criteria
This example adds a new notification subscription for all critical alerts raised by the monitor that has the display name ContosoMonitor. The first command uses the Get-SCOMNotificationSubscriber cmdlet to get subscribers and stores the result in the $Subscriber variable. The second command uses the Get-SCOMNotificationChannel cmdlet to get the notification channel, and stores the result in the $Channel variable. The third command uses the Get-SCOMMonitor cmdlet and stores the result in the $Monitor variable. The fourth command stores the XML criteria in the $Criteria variable. The fifth command uses the Add-SCOMNotificationSubscription cmdlet with the Name , Subscriber , Channel , and Criteria parameters.

Parameters

-BccSubscriber

Specifies an array of subscribers to blind carbon copy (BCC) on a message for a subscription.

Type:NotificationRecipient[]
Required:False
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-CcSubscriber

Specifies an array of subscribers to carbon copy (CC) on a message for a subscription.

Type:NotificationRecipient[]
Required:False
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-Channel

Specifies an array of notification channels.
To obtain a notification channel object, use the Get-SCOMNotificationChannel cmdlet.

Type:Object[]
Required:True
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-ComputerName

Specifies an array of names of computers.
The cmdlet establishes temporary connections with management groups for these computers.
You can use NetBIOS names, IP addresses, or fully qualified domain names (FQDNs).
To specify the local computer, type the computer name, localhost, or a dot (.).

Type:String[]
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Credential

Specifies a PSCredential object for the management group connection.
To obtain a PSCredential object, use the Get-Credential cmdlet.
For more information, type Get-Help Get-Credential.

Type:PSCredential
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Criteria

Specifies the criteria xml that indicates how to filter alerts for this subscription.
Criteria can filter on particular rules or monitors, or properties of the alert, but cannot filter on classes or groups.

You can manually copy the criteria xml from an existing subscription.
To obtain the criteria xml from an existing subscription, use this model: $subscription = Get-SCOMNotificationSubscription | Select-Object -First 1 $criteria = $subscription.Configuration.Criteria.

Type:String
Required:False
Position:3
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-Delay

Specifies a delay, in HH:MM:SS, for sending notifications if conditions remain unchanged for this period of time.
By default, Operations Manager sends notifications immediately.

Type:TimeSpan
Required:False
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-Description

Specifies a description for the notification subscription.
If you do not specify a description, the parameter defaults to the value of the DisplayName parameter.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-Disabled

Indicates that the cmdlet creates a subscription but leaves it in a disabled state.

Type:SwitchParameter
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-DisplayName

Specifies a display name for the subscription.
If you do not specify a description, the parameter defaults to the value of the Name parameter.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-Name

Specifies a name for the subscription.

Type:String
Required:True
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName, ByValue)
Accept wildcard characters:False

-OnlyOnResolutionChange

Indicates that the notification occurs only when the resolution state of the alert changes.

Type:SwitchParameter
Required:False
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-PollingInterval

Specifies a polling interval for alerts.
If you do not specify this parameter, the interval defaults to 1 minute.

Type:TimeSpan
Required:False
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-SCSession

Specifies an array of Connection objects.
To obtain a Connection object, use the Get-SCManagementGroupConnection cmdlet.

Type:Connection[]
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Subscriber

Specifies an array of subscribers for this subscription.
To obtain a notification subscriber object, use the Get-SCOMNotificationSubscriber cmdlet.

Type:NotificationRecipient[]
Required:True
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Required:False
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs.
The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Required:False
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False