How to Logoff Remote Desktop Sessions from the Command Line

Wednesday, February 17, 2016
It's happened to all of us. You try to logon to an administrative remote desktop on a server, but you can't because both administrative RDP sessions are in use. Oftentimes this is because other admins have simply disconnected their remote desktop session, rather than logoff as they should.

Here's a simple way to determine which sessions are logged on and how to log one or more of them off remotely from the command line. These procedures assume you are running them as a Domain Admin.
  • From an elevated CMD prompt, type the following command to find out who is logged on:
qwinsta /server:<servername>
The output will show who's logged on to the console (if anyone) and the various RDP sessions in use. It also displays the session ID, which is important for the next command.

Output from quinsta /server:<servername>

  • Next, run the LOGOFF command, specifying the server and session ID you want to logoff:
logoff /server:<servername> <session ID> /v
logoff /server:<servername>

This will logoff the remote session you specified. Note that if there are any open files in the remote desktop session, changes to that data may be lost.

No comments:

Post a Comment

Thank you for your comment! It is my hope that you find the information here useful. Let others know if this post helped you out, or if you have a comment or further information.