Add-SCOMNotificationSubscription
Adds a notification subscription.
Syntax
Default (Default)
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 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 = @"
>><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.
Parameter properties
Type: | NotificationRecipient[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-CcSubscriber
Specifies an array of subscribers to carbon copy (CC) on a message for a subscription.
Parameter properties
Type: | NotificationRecipient[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Channel
Specifies an array of notification channels. To obtain a notification channel object, use the Get-SCOMNotificationChannel cmdlet.
Parameter properties
Type: | Object[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | 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 (.).
Parameter properties
Type: | String[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
Supports wildcards: | False |
DontShow: | False |
Aliases: | cf |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | 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
.
Parameter properties
Type: | PSCredential |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | 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
.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | 3 |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | 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.
Parameter properties
Type: | TimeSpan |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | 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.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Disabled
Indicates that the cmdlet creates a subscription but leaves it in a disabled state.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | 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.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Name
Specifies a name for the subscription.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | 1 |
Mandatory: | True |
Value from pipeline: | True |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-OnlyOnResolutionChange
Indicates that the notification occurs only when the resolution state of the alert changes.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-PollingInterval
Specifies a polling interval for alerts. If you do not specify this parameter, the interval defaults to 1 minute.
Parameter properties
Type: | TimeSpan |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-SCSession
Specifies an array of Connection objects. To obtain a Connection object, use the Get-SCManagementGroupConnection cmdlet.
Parameter properties
Type: | Connection[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Subscriber
Specifies an array of subscribers for this subscription. To obtain a notification subscriber object, use the Get-SCOMNotificationSubscriber cmdlet.
Parameter properties
Type: | NotificationRecipient[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
Supports wildcards: | False |
DontShow: | False |
Aliases: | wi |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.