commands

^

Install-DbaAgentAdminAlert

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Install-DbaAgentAdminAlert on GitHub.
Want to see the Bill Of Health for this command? Check out Install-DbaAgentAdminAlert.

Synopsis

Creates SQL Server Agent alerts commonly needed by DBAs

Description

Creates SQL Server Agent alerts commonly needed by DBAs

You can specify an operator to use for the alert, or it will use any operator it finds if there is just one.

Alternatively, if you specify both an operator name and an email, it will create the operator if it does not exist.

Syntax

Install-DbaAgentAdminAlert
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Category] <String>]
    [[-Database] <String>]
    [[-Operator] <String>]
    [[-OperatorEmail] <String>]
    [[-DelayBetweenResponses] <Int32>]
    [-Disabled]
    [[-EventDescriptionKeyword] <String>]
    [[-EventSource] <String>]
    [[-JobId] <String>]
    [[-ExcludeSeverity] <Int32[]>]
    [[-ExcludeMessageId] <Int32[]>]
    [[-NotificationMessage] <String>]
    [[-NotifyMethod] <String>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Install-DbaAgentAdminAlert -SqlInstance sql1

Creates alerts for severity 17-25 and messages 823-825 on sql1

Required Parameters

-SqlInstance

The target SQL Server instance or instances

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential). Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported. For MFA support, please use Connect-DbaInstance.

Alias
Required False
Pipeline false
Default Value
-Category

The name of the category for the alert. If not specified, the alert will be created in the 'Uncategorized' category. If the category does not exist, it will be created.

Alias
Required False
Pipeline false
Default Value
-Database

The name of the database to which the alert applies

Alias
Required False
Pipeline false
Default Value
-Operator

The name of the operator to use in the alert

Alias
Required False
Pipeline false
Default Value
-OperatorEmail

If a the specified operator does not exist and an OperatorEmail is specified, the operator will be created

Alias
Required False
Pipeline false
Default Value
-DelayBetweenResponses

The delay (in seconds) between responses to the alert

Alias
Required False
Pipeline false
Default Value 0
-Disabled

Whether the alert is disabled

Alias
Required False
Pipeline false
Default Value False
-EventDescriptionKeyword

The keyword to search for in the event description

Alias
Required False
Pipeline false
Default Value
-EventSource

The source of the event

Alias
Required False
Pipeline false
Default Value
-JobId

The GUID ID of the job to execute when the alert is triggered

Alias
Required False
Pipeline false
Default Value 00000000-0000-0000-0000-000000000000
-ExcludeSeverity

Exclude specific severities from the batch. By default, severities 17-25 are included.

Alias
Required False
Pipeline false
Default Value
-ExcludeMessageId

Exclude specific message IDs from the batch. By default, mesasage IDs 823-825 are included.

Alias
Required False
Pipeline false
Default Value
-NotificationMessage

The message to send when the alert is triggered

Alias
Required False
Pipeline false
Default Value
-NotifyMethod

The method to use to notify the user of the alert. Valid values are 'None', 'NotifyEmail', 'Pager', 'NetSend', 'NotifyAll'. It is NotifyAll by default.

Alias
Required False
Pipeline false
Default Value NotifyAll
Accepted Values None,NotifyEmail,Pager,NetSend,NotifyAll
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

Alias cf
Required False
Pipeline false
Default Value