Test‑SqlDscAgentAlert - dsccommunity/SqlServerDsc GitHub Wiki

SYNOPSIS

Tests if a SQL Agent Alert exists and has the desired properties.

SYNTAX

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

DESCRIPTION

This command tests if a SQL Agent Alert exists on a SQL Server Database Engine instance and optionally validates its properties.

EXAMPLES

EXAMPLE 1

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
Test-SqlDscAgentAlert -ServerObject $serverObject -Name 'MyAlert'

Tests if the SQL Agent Alert named 'MyAlert' exists.

EXAMPLE 2

$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.

EXAMPLE 3

$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.

PARAMETERS

-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: 4
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: (All)
Aliases:

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

-ServerObject

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

-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: 3
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.

OUTPUTS

[System.Boolean]

NOTES

RELATED LINKS

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