Test‑SqlDscAgentAlertProperty - dsccommunity/SqlServerDsc GitHub Wiki

SYNOPSIS

Tests if a SQL Agent Alert has the specified properties.

SYNTAX

ByServerAndName (Default)

Test-SqlDscAgentAlertProperty -ServerObject <Server> -Name <String> [-Severity <Int32>] [-MessageId <Int32>]
 [<CommonParameters>]

ByAlertObject

Test-SqlDscAgentAlertProperty -AlertObject <Alert> [-Severity <Int32>] [-MessageId <Int32>]
 [<CommonParameters>]

DESCRIPTION

This command tests if a SQL Agent Alert on a SQL Server Database Engine instance has the specified properties. At least one property parameter must be specified.

EXAMPLES

EXAMPLE 1

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
Test-SqlDscAgentAlertProperty -ServerObject $serverObject -Name 'MyAlert' -Severity 16

Tests if the SQL Agent Alert named 'MyAlert' exists and has severity level 16.

EXAMPLE 2

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Test-SqlDscAgentAlertProperty -Name 'MyAlert' -MessageId 50001

Tests if the SQL Agent Alert named 'MyAlert' exists and has message ID 50001.

EXAMPLE 3

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$alertObject = $serverObject | Get-SqlDscAgentAlert -Name 'MyAlert'
$alertObject | Test-SqlDscAgentAlertProperty -Severity 16

Tests if the SQL Agent Alert has severity level 16 using alert object pipeline input.

PARAMETERS

-AlertObject

Specifies the SQL Agent Alert object to test.

Type: Alert
Parameter Sets: ByAlertObject
Aliases:

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

-MessageId

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: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-Name

Specifies the name of the SQL Agent Alert to test.

Type: String
Parameter Sets: ByServerAndName
Aliases:

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

-ServerObject

Specifies current server connection object.

Type: Server
Parameter Sets: ByServerAndName
Aliases:

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

-Severity

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: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

Microsoft.SqlServer.Management.Smo.Server

SQL Server Database Engine instance object.

Microsoft.SqlServer.Management.Smo.Agent.Alert

SQL Agent Alert object.

OUTPUTS

[System.Boolean]

NOTES

RELATED LINKS

⚠️ **GitHub.com Fallback** ⚠️