Set‑SqlDscAgentAlert - dsccommunity/SqlServerDsc GitHub Wiki

SYNOPSIS

Updates a SQL Agent Alert.

SYNTAX

ServerObject

Set-SqlDscAgentAlert -ServerObject <Server> -Name <String> [-Severity <Int32>] [-MessageId <Int32>] [-PassThru]
 [-Refresh] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

AlertObject

Set-SqlDscAgentAlert -AlertObject <Alert> [-Severity <Int32>] [-MessageId <Int32>] [-PassThru] [-Force]
 [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

This command updates an existing SQL Agent Alert on a SQL Server Database Engine instance.

EXAMPLES

EXAMPLE 1

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
Set-SqlDscAgentAlert -ServerObject $serverObject -Name 'MyAlert' -Severity 16

Updates the SQL Agent Alert named 'MyAlert' to severity level 16.

EXAMPLE 2

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$alertObject = $serverObject | Get-SqlDscAgentAlert -Name 'MyAlert'
$alertObject | Set-SqlDscAgentAlert -MessageId 50001

Updates the SQL Agent Alert using pipeline input with alert object.

EXAMPLE 3

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$updatedAlert = $serverObject | Set-SqlDscAgentAlert -Name 'MyAlert' -Severity 16 -PassThru

Updates the alert and returns the updated object.

EXAMPLE 4

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
Set-SqlDscAgentAlert -ServerObject $serverObject -Name 'MyAlert' -Severity 16 -Force

Updates the SQL Agent Alert named 'MyAlert' to severity level 16 without prompting for confirmation.

PARAMETERS

-AlertObject

Specifies an alert object to update.

Type: Alert
Parameter Sets: AlertObject
Aliases:

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

-Force

Specifies that the alert should be updated without prompting for confirmation.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-MessageId

Specifies the message ID for the SQL Agent Alert. Valid range is 0 to 2147483647. Cannot be used together with Severity.

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

Type: String
Parameter Sets: ServerObject
Aliases:

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

-PassThru

If specified, the updated alert object will be returned.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-Refresh

Specifies that the alert object should be refreshed before updating. This is helpful when alerts could have been modified outside of the ServerObject, for example through T-SQL.

Type: SwitchParameter
Parameter Sets: ServerObject
Aliases:

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

-ServerObject

Specifies current server connection object.

Type: Server
Parameter Sets: ServerObject
Aliases:

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

-Severity

Specifies the severity level for the SQL Agent Alert. Valid range is 0 to 25. Cannot be used together with MessageId.

Type: Int32
Parameter Sets: (All)
Aliases:

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

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

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

-WhatIf

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

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
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 to update.

OUTPUTS

Microsoft.SqlServer.Management.Smo.Agent.Alert

Returned when parameter PassThru is specified.

None

No output is returned unless PassThru is specified.

NOTES

RELATED LINKS

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