Thor Logo dbatools

Get-DbaDbServiceBrokerService

View Source
Ant Green (@ant_green)
Windows, Linux, macOS

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

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

 

Examples

 

Example: 1
PS C:\> Get-DbaDbServiceBrokerService -SqlInstance sql2016

Gets all database service broker queues

Example: 2
PS C:\> Get-DbaDbServiceBrokerService -SqlInstance Server1 -Database db1

Gets the service broker queues for the db1 database

Example: 3
PS C:\> Get-DbaDbServiceBrokerService -SqlInstance Server1 -ExcludeDatabase db1

Gets the service broker queues for all databases except db1

Example: 4
PS C:\> Get-DbaDbServiceBrokerService -SqlInstance Server1 -ExcludeSystemService

Gets the service broker queues for all databases that are not system objects

Optional Parameters

-SqlInstance

The target SQL Server instance or instances

PropertyValue
Alias
RequiredFalse
Pipelinetrue (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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse

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.