Author | Chrissy LeMaire (@cl), netnerds.net |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out New-DbaAgentAlert on GitHub.
Want to see the Bill Of Health for this command? Check out New-DbaAgentAlert.
Creates a new SQL Server Agent alert
Creates a new SQL Server Agent alert
New-DbaAgentAlert
[-SqlInstance] <DbaInstanceParameter[]>
[[-SqlCredential] <PSCredential>]
[-Alert] <String>
[[-Category] <String>]
[[-Database] <String>]
[[-Operator] <String[]>]
[[-DelayBetweenResponses] <Int32>]
[-Disabled]
[[-EventDescriptionKeyword] <String>]
[[-EventSource] <String>]
[[-JobId] <String>]
[[-Severity] <Int32>]
[[-MessageId] <Int32>]
[[-NotificationMessage] <String>]
[[-PerformanceCondition] <String>]
[[-WmiEventNamespace] <String>]
[[-WmiEventQuery] <String>]
[[-NotifyMethod] <String>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> $parms = @{
SqlInstance = "sql01"
Severity = 18
Alert = "Severity 018 - Nonfatal Internal Error"
DelayBetweenResponses = 60
NotifyMethod = "NotifyEmail"
}
PS C:\> $alert = New-DbaAgentAlert @parms
Creates a new alert for severity 18 with the name Severity 018 - Nonfatal Internal Error.
It will send an email to the default operator and wait 60 seconds before sending another email.
The target SQL Server instance or instances
Alias | |
Required | True |
Pipeline | true (ByValue) |
Default Value |
The name of the alert to create
Alias | |
Required | True |
Pipeline | false |
Default Value |
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 |
The name of the category for the alert
Alias | |
Required | False |
Pipeline | false |
Default Value |
The name of the database to which the alert applies
Alias | |
Required | False |
Pipeline | false |
Default Value |
The name of the operator to use in the alert
Alias | |
Required | False |
Pipeline | false |
Default Value |
The delay (in seconds) between responses to the alert
Alias | |
Required | False |
Pipeline | false |
Default Value | 60 |
Whether the alert is disabled
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
The keyword to search for in the event description
Alias | |
Required | False |
Pipeline | false |
Default Value |
The source of the event
Alias | |
Required | False |
Pipeline | false |
Default Value |
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 |
The severity level for the alert. Valid values are 0-25
Alias | |
Required | False |
Pipeline | false |
Default Value | 0 |
The message ID for the alert
Alias | |
Required | False |
Pipeline | false |
Default Value | 0 |
The message to send when the alert is triggered
Alias | |
Required | False |
Pipeline | false |
Default Value |
The performance condition for the alert
Alias | |
Required | False |
Pipeline | false |
Default Value |
The namespace of the WMI event to use in the alert
Alias | |
Required | False |
Pipeline | false |
Default Value |
The WMI query to use in the alert
Alias | |
Required | False |
Pipeline | false |
Default Value |
The method to use to notify the user of the alert. Valid values are 'None', 'NotifyEmail', 'Pager', 'NetSend', 'NotifyAll'. It is NotifyAll by default.
The Pager and net send options will be removed from SQL Server Agent in a future version of Microsoft SQL Server.
Avoid using these features in new development work, and plan to modify applications that currently use these features.
Alias | |
Required | False |
Pipeline | false |
Default Value | NotifyAll |
Accepted Values | None,NotifyEmail,Pager,NetSend,NotifyAll |
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 |
Shows what would happen if the command were to run. No actions are actually performed.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts you for confirmation before executing any changing operations within the command.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |