Get-DbaDbServiceBrokerQueue
View SourceSynopsis
Gets database service broker queues
Description
Gets database Sservice broker queue
Syntax
Get-DbaDbServiceBrokerQueue
[[-SqlInstance] <DbaInstanceParameter[]>]
[[-SqlCredential] <PSCredential>]
[[-Database] <Object[]>]
[[-ExcludeDatabase] <Object[]>]
[-ExcludeSystemQueue]
[-EnableException]
[<CommonParameters>]
Examples
Example: 1
PS C:\> Get-DbaDbServiceBrokerQueue -SqlInstance sql2016
Gets all database service broker queues
Example: 2
PS C:\> Get-DbaDbServiceBrokerQueue -SqlInstance Server1 -Database db1
Gets the service broker queues for the db1 database
Example: 3
PS C:\> Get-DbaDbServiceBrokerQueue -SqlInstance Server1 -ExcludeDatabase db1
Gets the service broker queues for all databases except db1
Example: 4
PS C:\> Get-DbaDbServiceBrokerQueue -SqlInstance Server1 -ExcludeSystemQueue
Gets the service broker queues for all databases that are not system objects
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 retrieve Service Broker queues from. Accepts wildcards for pattern matching.
Use this when you need to focus on specific databases instead of scanning all databases on the instance.
| Property | Value |
|---|---|
| Alias | |
| Required | False |
| Pipeline | false |
| Default Value |
-ExcludeDatabase
Specifies databases to exclude from the Service Broker queue retrieval. Accepts wildcards for pattern matching.
Useful when you want to scan most databases but skip specific ones like test or development databases.
| Property | Value |
|---|---|
| Alias | |
| Required | False |
| Pipeline | false |
| Default Value |
-ExcludeSystemQueue
Excludes system-created Service Broker queues from the results, showing only user-created queues.
Use this to focus on application-specific queues and filter out SQL Server’s internal messaging queues.
| 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.ServiceBrokerQueue
Returns one ServiceBrokerQueue object per queue found across the specified databases. System queues are included by default but can be excluded using the -ExcludeSystemQueue 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 queue
- Schema: The schema containing the queue
- QueueID: The unique object ID of the queue within the database
- CreateDate: DateTime when the queue was created
- DateLastModified: DateTime when the queue was last modified
- Name: The name of the Service Broker queue
- ProcedureName: Name of the stored procedure that activates the queue (if configured)
- ProcedureSchema: Schema containing the activation procedure
Additional properties available (from SMO ServiceBrokerQueue object):
- IsSystemObject: Boolean indicating if this is a system queue created by SQL Server
- IsActivationEnabled: Boolean indicating if queue activation is enabled
- MaxReaders: Maximum number of simultaneous queue readers
- State: Queue state (Available, Unavailable, etc.)
- Owner: The principal that owns the queue
- Urn: The Urn identifier for the queue All properties from the base SMO ServiceBrokerQueue object are accessible via Select-Object * even though only default properties are displayed.
dbatools