Add-SCOMNotificationSubscription

Adds a notification subscription.

Syntax

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

Description

The Add-SCOMNotificationSubscription cmdlet adds a notification subscription in System Center - 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 = @"
>><And xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>><Expression>
>><SimpleExpression>
>><ValueExpression>
>><Property>ProblemId</Property>
>></ValueExpression>
>><Operator>Equal</Operator>
>><ValueExpression>
>><Value>$($monitor.Id)</Value>
>></ValueExpression>
>></SimpleExpression>
>></Expression>
>><Expression>
>><SimpleExpression>
>><ValueExpression>
>><Property>Severity</Property>
>></ValueExpression>
>><Operator>Equal</Operator>
>><ValueExpression>
>><Value>2</Value>
>></ValueExpression>
>></SimpleExpression>
>></Expression>
>>"@
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[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-CcSubscriber

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

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

-Channel

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

Type:Object[]
Position:Named
Default value:None
Required:True
Accept pipeline input:True
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[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
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
Position:Named
Default value:None
Required:False
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
Position:3
Default value:None
Required:False
Accept pipeline input:True
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
Position:Named
Default value:None
Required:False
Accept pipeline input:True
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
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Disabled

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

Type:SwitchParameter
Position:Named
Default value:None
Required:False
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
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Name

Specifies a name for the subscription.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-OnlyOnResolutionChange

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

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:True
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
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-SCSession

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

Type:Connection[]
Position:Named
Default value:None
Required:False
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[]
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

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

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