Enable-sqmServiceBroker
Configuration
sqmSQLTool v1.8.2+ · Enable
✓ -WhatIf / -Force ⚠ ConfirmImpact: High
- Set database to
SINGLE_USER WITH ROLLBACK IMMEDIATE— disconnects all active sessions - Execute
ALTER DATABASE … SET ENABLE_BROKER - Restore
MULTI_USER(rollback to MULTI_USER automatically if step 2 fails) - Create
SSBEndpointon TCP port 4022 with WINDOWS authentication (skipped if already exists; failure is a warning, not fatal) - Grant
CONNECT ON ENDPOINT::SSBEndpoint TO PUBLIC(warning on failure)
A TXT log file is written for every run. Returns a
[PSCustomObject] with Status = 'SUCCESS' (broker confirmed enabled) or 'PARTIAL' (endpoint step had issues). Suitable for both standalone and Always On configurations.
Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -SqlInstance | string | Optional | $env:COMPUTERNAME | SQL Server instance. Accepts pipeline input. |
| -DatabaseName | string | Required | — | Database on which Service Broker is enabled. |
| -SqlCredential | PSCredential | Optional | — | Credential for the SQL Server connection. |
| -Force | switch | Switch | $false | Skip the ShouldProcess confirmation prompt. |
| -OutputPath | string | Optional | C:\System\WinSrvLog\MSSQL | Directory for the log file. Created if missing. |
| -ContinueOnError | switch | Switch | $false | Swallow the outer catch and return nothing instead of re-throwing. |
| -EnableException | switch | Switch | $false | Always re-throw on error (overrides -ContinueOnError). |
| -WhatIf / -Confirm | switch | Optional | — | ShouldProcess (ConfirmImpact: High) guards the entire operation. Returns $null when cancelled. |
Execution Flow
Examples
Enable Service Broker on the local default instance
Enable-sqmServiceBroker -DatabaseName "OperationsManager"
Enable on a remote instance, skip confirmation prompt
Enable-sqmServiceBroker -SqlInstance "SQL01" -DatabaseName "OperationsManager" -Force