How to Set Up Remote Desktop Connection Broker on Windows Server 2019
The Remote Desktop Connection Broker (RD Connection Broker) is a role service in Windows Server 2019 that manages user connections in a Remote Desktop Services deployment. It routes users to the least-loaded RD Session Host in a session collection, reconnects users to their existing disconnected sessions, and manages access to virtual desktop collections. Without an RD Connection Broker, users connecting to a load-balanced RDS farm may not be reconnected to their existing session, resulting in multiple disconnected sessions and lost work.
Role of the Connection Broker in RDS Architecture
In a scalable RDS deployment, multiple RD Session Host servers share the user load. When a user connects, the Connection Broker checks whether they have an existing disconnected session on any RDSH server in the farm. If a session exists, the user is reconnected to it regardless of which server it is on. If no session exists, the Connection Broker directs the user to the least-loaded server in the collection. The Connection Broker also provides a single point for publishing RemoteApp programs and managing User Profile Disks.
Installing the RD Connection Broker Role
The Connection Broker is typically installed on a dedicated server or combined with the RD Web Access server. It should not be installed on the RD Session Host servers themselves to avoid contention. Install the role with PowerShell.
# Install RD Connection Broker
Install-WindowsFeature -Name RDS-Connection-Broker -IncludeManagementTools
# Verify
Get-WindowsFeature -Name RDS-Connection-Broker
For a quick single-server deployment where all roles are on one machine (acceptable for small environments up to around 20 users):
Install-WindowsFeature -Name RDS-RD-Server, RDS-Connection-Broker, RDS-Web-Access, RDS-Licensing -IncludeManagementTools
Creating the RDS Deployment
After installing the roles, use the New-RDSessionDeployment cmdlet to create the initial RDS deployment. This cmdlet configures the Connection Broker, adds Session Hosts to the deployment, and sets up Web Access. All servers must be domain-joined and must have the respective role services installed before running this command.
# Create the RDS deployment
# Run this on the Connection Broker server
New-RDSessionDeployment `
-ConnectionBroker "rdcb01.corp.local" `
-SessionHost @("rdsh01.corp.local", "rdsh02.corp.local") `
-WebAccessServer "rdweb01.corp.local"
Configuring the Connection Broker for Load Balancing
The Connection Broker uses a weighted round-robin algorithm to distribute new sessions. Each RDSH server has a relative weight value; higher weights attract proportionally more new connections. This allows you to send more sessions to more powerful servers in a mixed-hardware farm.
# Set the load balancing weight for an RD Session Host
# Weight values: 1 (lowest priority) to 100 (highest)
Set-RDSessionHost `
-SessionHost "rdsh01.corp.local" `
-ConnectionBroker "rdcb01.corp.local" `
-NewConnectionAllowed Yes `
-LoadBalancingWeight 100
Set-RDSessionHost `
-SessionHost "rdsh02.corp.local" `
-ConnectionBroker "rdcb01.corp.local" `
-NewConnectionAllowed Yes `
-LoadBalancingWeight 75
# View current load balancing configuration
Get-RDSessionHost -CollectionName "StandardDesktop" -ConnectionBroker "rdcb01.corp.local" |
Select-Object SessionHost, NewConnectionAllowed, LoadBalancingWeight
Creating Session Collections
A session collection is a group of RD Session Host servers that share a common configuration, publish the same RemoteApp programs, and are managed as a unit by the Connection Broker. Create session collections to separate different user groups or application sets.
# Create a new session collection
New-RDSessionCollection `
-CollectionName "StandardDesktop" `
-SessionHost @("rdsh01.corp.local", "rdsh02.corp.local") `
-ConnectionBroker "rdcb01.corp.local" `
-CollectionDescription "Standard desktop collection for knowledge workers"
# Create a collection for a specific department
New-RDSessionCollection `
-CollectionName "AccountingApps" `
-SessionHost "rdsh03.corp.local" `
-ConnectionBroker "rdcb01.corp.local" `
-CollectionDescription "Accounting application collection"
Configuring Connection Broker High Availability
For production environments, configure Connection Broker High Availability (HA) to eliminate the Connection Broker as a single point of failure. Connection Broker HA requires a SQL Server database (SQL Server 2012 or later, or SQL Server Express for smaller deployments) to store the session state information shared between multiple Connection Broker instances.
# Configure Connection Broker HA
# First, ensure SQL Server is accessible and a database for the Connection Broker exists
# Set Connection Broker to high availability mode
Set-RDConnectionBrokerHighAvailability `
-ConnectionBroker "rdcb01.corp.local" `
-DatabaseConnectionString "DRIVER=SQL Server Native Client 11.0;SERVER=sqlserver.corp.local;Trusted_Connection=Yes;APP=Remote Desktop Services Connection Broker;Database=RDConnectionBrokerDB" `
-DatabaseFilePath "C:RDConnectionBrokerRDConnectionBroker.mdf" `
-ClientAccessName "rds.corp.local"
The ClientAccessName is a DNS name that clients use to connect to the Connection Broker HA cluster. Create a DNS A record pointing this name to the active Connection Broker’s IP address, and use DNS round-robin or a load balancer for the HA pair.
Adding an Additional Connection Broker to an HA Deployment
# Add a second Connection Broker to the HA deployment
Add-RDServer `
-Server "rdcb02.corp.local" `
-Role "RDS-CONNECTION-BROKER" `
-ConnectionBroker "rds.corp.local"
Monitoring Connection Broker Performance
Monitor the Connection Broker to ensure sessions are being distributed properly and to identify overloaded Session Hosts.
# Get session statistics for all RDSH servers in a collection
Get-RDUserSession -CollectionName "StandardDesktop" -ConnectionBroker "rdcb01.corp.local" |
Group-Object HostServer | Select-Object Name, Count | Sort-Object Count -Descending
# Get total sessions per server
Get-RDSessionHost -CollectionName "StandardDesktop" -ConnectionBroker "rdcb01.corp.local" |
ForEach-Object {
$Sessions = (Get-RDUserSession -ConnectionBroker "rdcb01.corp.local" |
Where-Object { $_.HostServer -eq $_.SessionHost }).Count
[PSCustomObject]@{
Server = $_.SessionHost
Weight = $_.LoadBalancingWeight
SessionCount = $Sessions
}
}
Configuring Session Collection Settings
Set collection-wide configuration such as User Profile Disk paths, session time limits, and security settings through Set-RDSessionCollectionConfiguration.
# Configure session collection settings
Set-RDSessionCollectionConfiguration `
-CollectionName "StandardDesktop" `
-ConnectionBroker "rdcb01.corp.local" `
-IdleSessionLimitMin 30 `
-DisconnectedSessionLimitMin 60 `
-ActiveSessionLimitMin 480 `
-EnableUserProfileDisk $true `
-MaxUserProfileDiskSizeGB 20 `
-DiskPath "\fileserverUPDsStandardDesktop" `
-SecurityLayer Negotiate `
-EncryptionLevel High `
-AuthenticateUsingNLA $true
Removing an RDSH Server from a Collection
To drain and remove an RDSH server from the collection for maintenance, first prevent new connections to it, then wait for or manually remove existing sessions.
# Stop new connections to an RDSH server (drain mode)
Set-RDSessionHost `
-SessionHost "rdsh01.corp.local" `
-ConnectionBroker "rdcb01.corp.local" `
-NewConnectionAllowed No
# View remaining sessions on the server being drained
Get-RDUserSession -ConnectionBroker "rdcb01.corp.local" |
Where-Object { $_.HostServer -eq "rdsh01.corp.local" } |
Select-Object UserName, SessionId, SessionState, IdleTime
# Remove the server from the collection after draining
Remove-RDSessionHost `
-SessionHost "rdsh01.corp.local" `
-ConnectionBroker "rdcb01.corp.local" `
-Force
Conclusion
The RD Connection Broker is the linchpin of a scalable Windows Server 2019 RDS deployment. It provides session reconnection, load balancing, collection management, and centralised configuration for RemoteApp programs and User Profile Disks. For production deployments, configuring Connection Broker HA with a SQL Server backend eliminates a critical single point of failure. PowerShell cmdlets for the RDS stack provide full automation capability for deploying, scaling, and maintaining Connection Broker deployments at any scale.