---
title: "Get-DbaDbServiceBrokerService"
description: "Retrieves Service Broker services from SQL Server databases for auditing and troubleshooting messaging configurations"
url: "https://dbatools.io/Get-DbaDbServiceBrokerService/"
availability: "Windows, Linux, macOS"
tags: ["Service", "ServiceBroker"]
author: "Ant Green (@ant_green)"
source: "https://github.com/dataplat/dbatools/blob/master/public/Get-DbaDbServiceBrokerService.ps1"
last_updated: "2024-01-01"
---

# Get-DbaDbServiceBrokerService

## Synopsis

Retrieves Service Broker services from SQL Server databases for auditing and troubleshooting messaging configurations

## Description

Retrieves detailed information about Service Broker services configured in SQL Server databases, including service names, associated queues, schemas, and ownership details. Service Broker services define the endpoints for reliable messaging between applications and databases. This function helps DBAs audit Service Broker implementations, troubleshoot message-based applications, and document messaging configurations for compliance or migration planning.

## Syntax

```powershell
Get-DbaDbServiceBrokerService
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-Database] <Object[]>]
    [[-ExcludeDatabase] <Object[]>]
    [-ExcludeSystemService]
    [-EnableException]
    [<CommonParameters>]

```

## Examples

### Example 1: Gets all database service broker queues

```powershell
PS C:\> Get-DbaDbServiceBrokerService -SqlInstance sql2016
```

### Example 2: Gets the service broker queues for the db1 database

```powershell
PS C:\> Get-DbaDbServiceBrokerService -SqlInstance Server1 -Database db1
```

### Example 3: Gets the service broker queues for all databases except db1

```powershell
PS C:\> Get-DbaDbServiceBrokerService -SqlInstance Server1 -ExcludeDatabase db1
```

### Example 4: Gets the service broker queues for all databases that are not system objects

```powershell
PS C:\> Get-DbaDbServiceBrokerService -SqlInstance Server1 -ExcludeSystemService
```

### Optional Parameters

##### -SqlInstance

The target SQL Server instance or instances

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | true (ByValue) |
| Default Value |  |

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

##### -Database

Specifies which databases to query for Service Broker services. Accepts multiple database names.  
Use this when you need to limit the search to specific databases instead of scanning all databases on the instance.

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

##### -ExcludeDatabase

Excludes specific databases from the Service Broker service search. Accepts multiple database names.  
Useful when you want to audit most databases but skip known databases without Service Broker configurations.

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

##### -ExcludeSystemService

Excludes system-created Service Broker services from the results, showing only user-defined services.  
Use this to focus on custom messaging implementations and avoid clutter from built-in SQL Server services.

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

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

Returns one ServiceBrokerService object per Service Broker service found across the specified databases. System services are included by default but can be excluded using the -ExcludeSystemService parameter.

**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)
- Database: The name of the database containing the service
- Owner: The principal that owns the Service Broker service
- ServiceID: The unique object ID of the service within the database
- Name: The name of the Service Broker service
- QueueSchema: The schema containing the associated queue
- QueueName: The name of the queue associated with this service

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

- IsSystemObject: Boolean indicating if this is a system service created by SQL Server
- CreateDate: DateTime when the service was created
- DateLastModified: DateTime when the service was last modified
- State: Service state (Existing, Creating, Pending, etc.)
- Urn: The Urn identifier for the service
All properties from the base SMO ServiceBrokerService object are accessible via Select-Object * even though only default properties are displayed.

---

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