>NULL: April 2022

Thursday 14 April 2022

Useful commands for RDS Session Host servers

I recently had an issue where a user could not login, their session showed disconnected on the RDGateway but I could not log them out vis Server Manager, no session for the user was shown on the Session Host in Task Manager. I used the following commands to find the processes running under that user's account and end them. 

Some processes could not be ended but ending those I could allowed RDGateway to unregister the session and by denying logins to the host I was able to steer the user to another host.


To list the users logged in and obtain their Session ID

query session

To log off a session

logoff <Session ID>

To list all processes and find the Session ID related

query process *

To list processes and obtain the PID (process ID)

tasklist

To end a process

taskkill /F /PID <PID>

To log a user off from another server

Logoff <SessionID> /server:<hostname>