Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Windows Server 2019 / How to Remove RD Session Host from Remote Desktop Services Deployment

June 8, 2023 Windows Server 2016Windows Server 2019

How to Remove RD Session Host from Remote Desktop Services Deployment

To remove an RSDH host from a Remote Desktop Services session collection/farm, you can use the Server Manager graphical console or the Remove-RDSessionHost PowerShell cmdlet.

You can use the following PowerShell command if you want to remove an online RD Session host from a session collection on an RDS farm:

Remove-RDSessionHost -SessionHost @("rdsh2.woshub.com") -ConnectionBroker rdcb.woshub.com –verbose

VERBOSE: The specified RD Session Host server will be removed from the session collection.

If the RDSH server you want to remove is offline (dead/failed host when you can’t boot Windows, or the server hardware is damaged), you will receive the following error when trying to remove it from your RDS deployment:

WARNING: Unable to cleanup the RD Session Host server rdsh1.

Remove-RDSessionHost - Unable to cleanup the RD Session Host server

If you try to remove such a server running Remote Desktop Services Host role from an RDS deployment using the Server Manager, you will see this error:

Could not remove the configuration. Object reference not set to an instance of an object.

remote desktop host role - Could not remove the configuration. Object reference not set to an instance of an object.

Also, you can’t manage your RDS farm through Server Manager because after removing the RDSH host from the console, you’ll see the following warning:

The following servers in this deployment are not part of the server pool:
rdsh2.woshub.com
The servers must be added to the server pool.

To correctly remove a failed RDS host you will not return to your farm, you have to remove its metadata from the RD Connection Broker (RDCB) database.

To do it, connect to the RDCB database using SQL Management Studio.

  • If you are using a local Remote Desktop Connection Broker database based on Windows Internal Database (WID), use the following connection string to connect to the SQL instance: \\.\pipe\MICROSOFT##WID\tsql\query
  • If your RDCB database is running on a SQL Server or in a SQL Server Always On High Availability Group (if you are using a high-availability RD Connection Broker role), connect to the appropriate SQL Server Listener (you may get it using the command: Get-RDConnectionBrokerHighAvailability )

Run SQL Management Studio and connect to the database using an account with the local administrator privileges on the server.

connect rds database with SQL Management Studio

It is strongly recommended to backup the RD Connection Broker SQL database before making any changes.

Expand the RDCms database and look for the following tables containing entries about the RDS farm hosts:

  • rds.Server – a full list of servers in the Remote Desktop Services farm
  • rds.RoleRdsh – a list of servers with the RD Session Host role
  • rds.RoleRdcb — Connection Broker
  • rds.RoleRdls — RDS License Serversr
  • rds.RoleRdvh — Virtualization Hosts
  • rds.RoleRdwa — Web Access Hosts

In our case, only the RDSH role is running on the server, which means it is enough to delete its entries from the rds.Server and rds.RoleRdsh tables.

Look in the table for the ID of the RDSH server that you want to remove from the RDS deployment. In my example, it is ID 3.

RD configuration database

Use the following T-SQL query to remove the RDSH records from both tables of the Connection Broker database:

use RDCms;
delete from rds.RoleRdsh where ServerID = '3';
delete from rds.Server where Id = '3';

remove remote desktop server from RD database with T-sql

You don’t need to put other RDSH hosts in the drain mode.

Close the database and restart the Server Manager console. Open the RDS console, update the configuration, and make sure that the removed server no longer appears in the list of available RDS hosts.

removing dead host from rds deployment

You can also make sure that there is no removed server in the RDS farm using this command:

Get-RDServer

If you want to migrate the RD Connection Broker or RD Web Access roles to another server, use this guide.

1 comment
1
Facebook Twitter Google + Pinterest
previous post
How to Enable and Configure SSH Server on Windows with OpenSSH
next post
Install Windows Subsystem for Linux (WSL 2) on Windows 10/11

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

How to View and Change BIOS (UEFI) Settings...

September 13, 2023

How to Create UEFI Bootable USB Drive to...

September 11, 2023

1 comment

Francesco December 28, 2022 - 10:13 am

I found at this link (https://learn.microsoft.com/en-us/answers/questions/348334/remove-server-from-rds-deployment-after-decommissi.html?sort=votes) a trick to avoid installing SSMS and having to manually delete rows from the tables. Simply recreate the computer object in Active Directory, or restore it from the Active Directory Recycle Bin, and run the Remove-RDServer cmd let. It worked for me.

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • How to Downgrade Windows Server Edition or License
  • How to Sign an Unsigned Device Driver in Windows
  • Fix: Remote Desktop Licensing Mode is not Configured
  • Configuring Port Forwarding in Windows
  • How to Convert (Upgrade) Windows Server 2019/2016 Evaluation to Full Version?
  • How to Clean Up Large System Volume Information Folder on Windows?
  • Fixing “Winload.efi is Missing or Contains Errors” in Windows 10
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top