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.
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.
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:
- 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:
Run SQL Management Studio and connect to the database using an account with the local administrator privileges on the server.
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.
Use the following T-SQL query to remove the RDSH records from both tables of the Connection Broker database:
delete from rds.RoleRdsh where ServerID = '3';
delete from rds.Server where Id = '3';
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.
You can also make sure that there is no removed server in the RDS farm using this command: