Test‑SqlDscAgentAlert - dsccommunity/SqlServerDsc GitHub Wiki
Tests if a SQL Agent Alert exists and has the desired properties.
Test-SqlDscAgentAlert [-ServerObject] <Server> [-Name] <String> [[-Severity] <Int32>] [[-MessageId] <Int32>]
[<CommonParameters>]
This command tests if a SQL Agent Alert exists on a SQL Server Database Engine instance and optionally validates its properties.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
Test-SqlDscAgentAlert -ServerObject $serverObject -Name 'MyAlert'
Tests if the SQL Agent Alert named 'MyAlert' exists.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Test-SqlDscAgentAlert -Name 'MyAlert' -Severity 16
Tests if the SQL Agent Alert named 'MyAlert' exists and has severity level 16.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Test-SqlDscAgentAlert -Name 'MyAlert' -MessageId 50001
Tests if the SQL Agent Alert named 'MyAlert' exists and has message ID 50001.
Specifies the expected message ID for the SQL Agent Alert. Valid range is 0 to 2147483647. If specified, the command will return $true only if the alert exists and has this message ID.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
Specifies the name of the SQL Agent Alert to test.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies current server connection object.
Type: Server
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Specifies the expected severity level for the SQL Agent Alert. Valid range is 0 to 25. If specified, the command will return $true only if the alert exists and has this severity.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.