---
title: "Get-DbaAgentAlertCategory"
description: "Retrieves SQL Server Agent alert categories and their associated alert counts"
url: "https://dbatools.io/Get-DbaAgentAlertCategory/"
availability: "Windows, Linux, macOS"
tags: ["Agent", "Alert", "AlertCategory"]
author: "Patrick Flynn (@sqllensman)"
source: "https://github.com/dataplat/dbatools/blob/master/public/Get-DbaAgentAlertCategory.ps1"
last_updated: "2024-01-01"
---

# Get-DbaAgentAlertCategory

## Synopsis

Retrieves SQL Server Agent alert categories and their associated alert counts

## Description

Retrieves all SQL Server Agent alert categories from the target instances, showing how alerts are organized and grouped. Categories help DBAs manage alerts logically by grouping related notifications (such as severity-based alerts, database maintenance alerts, or custom business alerts). The function also returns a count of how many alerts are currently assigned to each category, making it useful for understanding your alerting structure and identifying unused or heavily-used categories.

## Syntax

```powershell
Get-DbaAgentAlertCategory
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Category] <String[]>]
    [-EnableException]
    [<CommonParameters>]

```

## Examples

### Example 1: Return all the agent alert categories

```powershell
PS C:\> Get-DbaAgentAlertCategory -SqlInstance sql1
```

### Example 2: Return all the agent alert categories that have the name &#39;Severity Alert&#39;

```powershell
PS C:\> Get-DbaAgentAlertCategory -SqlInstance sql1 -Category 'Severity Alert'
```

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

##### -Category

Specifies one or more alert category names to return from the SQL Server Agent. Accepts multiple values and wildcards are not supported.  
Use this when you need to examine specific alert categories rather than retrieving all categories on the instance.

| 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.Agent.AlertCategory**

Returns one AlertCategory object per alert category on the SQL Server instance. Custom properties are added to provide connection context and alert count information.

**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: The name of the alert category
- ID: The unique identifier of the alert category
- AlertCount: The number of alerts currently assigned to this category (integer)

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

- Parent: Reference to the parent JobServer object
- Urn: The Unified Resource Name that uniquely identifies the alert category
- State: The state of the object (Existing, Creating, Dropping, Pending)
All properties from the base SMO AlertCategory object are accessible by 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/
