---
title: "Get-DbaAgentAlert"
description: "Retrieves SQL Server Agent alert configurations from one or more instances"
url: "https://dbatools.io/Get-DbaAgentAlert/"
availability: "Windows, Linux, macOS"
tags: ["Agent", "Alert"]
author: "Klaas Vandenberghe (@PowerDBAKlaas)"
source: "https://github.com/dataplat/dbatools/blob/master/public/Get-DbaAgentAlert.ps1"
last_updated: "2024-01-01"
---

# Get-DbaAgentAlert

## Synopsis

Retrieves SQL Server Agent alert configurations from one or more instances

## Description

Retrieves alert configurations from SQL Server Agent, including alert names, types, severity levels, message IDs, and notification settings. Use this to audit alert configurations across multiple servers, troubleshoot missing or misconfigured alerts, or gather information for compliance reporting. The function returns detailed alert properties like enabled status, last occurrence dates, and response delays, making it essential for monitoring your alerting infrastructure and ensuring critical system events are properly configured for notification.

## Syntax

```powershell
Get-DbaAgentAlert
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Alert] <String[]>]
    [[-ExcludeAlert] <String[]>]
    [-EnableException]
    [<CommonParameters>]

```

## Examples

### Example 1: Returns all SQL Agent alerts on serverA and serverB\instanceB

```powershell
PS C:\> Get-DbaAgentAlert -SqlInstance ServerA,ServerB\instanceB
```

### Example 2: Returns SQL Agent alert on serverA and serverB\instanceB whose names match &#39;MyAlert*&#39;

```powershell
PS C:\> Get-DbaAgentAlert -SqlInstance ServerA,ServerB\instanceB -Alert MyAlert*
```

### Example 3: Returns all SQL Agent alerts on serverA and serverB\instanceB

```powershell
PS C:\> 'serverA','serverB\instanceB' | Get-DbaAgentAlert
```

### Required Parameters

##### -SqlInstance

The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.

| Property | Value |
| --- | --- |
| 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.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Alert

Specifies the specific SQL Agent alert names to retrieve from the target instances. Accepts wildcards for pattern matching.  
Use this when you need to check specific alerts like 'Severity 016*' or 'DB Mail*' instead of retrieving all alerts on the server.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -ExcludeAlert

Specifies SQL Agent alert names to exclude from the results. Accepts wildcards for pattern matching.  
Use this to filter out unwanted alerts when auditing or when you need to focus on specific alert categories without built-in system alerts.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

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

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

## Outputs

**Microsoft.SqlServer.Management.Smo.Alert**

Returns one Alert object per SQL Agent alert found on the specified instances.

**Default display properties (via Select-DefaultView):**

- ComputerName: The computer name of the SQL Server instance
- InstanceName: The SQL Server instance name
- SqlInstance: The full SQL Server instance name (computer\instance)
- Name: Name of the alert
- ID: Unique identifier of the alert in the msdb database
- JobName: Name of the job that responds to this alert (if any)
- AlertType: Type of alert (EventAlert, ErrorNumberAlert, etc.)
- CategoryName: Category name assigned to the alert
- Severity: SQL Server error severity level (0-25) that triggers this alert
- MessageId: SQL Server message ID that triggers this alert (if alert is message-based)
- IsEnabled: Boolean indicating if the alert is enabled
- DelayBetweenResponses: Delay in seconds between repeated alert responses
- LastRaised: DateTime when this alert was last triggered (dbatools custom property)
- OccurrenceCount: Number of times this alert has been raised

**Additional properties available (from SMO Alert object):**

- CategoryId: Unique identifier of the alert category
- CreateDate: DateTime when the alert was created
- DateLastModified: DateTime when the alert was last modified
- DatabaseName: Name of the database this alert applies to (for database-specific alerts)
- Urn: Uniform Resource Name for the SMO object
- State: SMO object state (Existing, Creating, Pending, etc.)

**Custom properties added by this function:**

- Notifications: DataTable from EnumNotifications() containing operators notified by this alert and their notification methods (Email, Pager, NetSend)
All properties from the base SMO Alert object are accessible even though only default properties are displayed without using Select-Object *.

---

Part of [dbatools](https://dbatools.io/), a free and open source PowerShell module for SQL Server administration. Full command index: https://dbatools.io/commands/
