Sometimes users forget to logoff their sessions from the Terminal Server computers. When you try to log on to those servers you get "There are no sessions left". In this situation, you need to disconnect user's session from the Terminal Server using either the Terminal Server Manager or command line tool. This article explains how you can use a command line tool from a remote computer to do so:
1. Steps for disconnecting a Sesion from a Single Server:
- Query all the sessions on the Terminal Server by running the following command:
Query Sessions /server:Server_Name
- Note down the ID of the session you want to disconnect.
- Run the following command to disconnect user's session from the Terminal Server
Logoff ID_Number /Server:Server_Name
2. Steps for disconnecting a Sesion from a Single Server:
Create a text file: Servers.txt
Copy all the server names in the text file.
Next run the following command to see the Session ID on one server:
Query Sessions /server:Server_Name
- Note down the ID of the session you want to disconnect.
- Run the following command to disconnect user's session from all the Terminal Servers
For /F "Tokens=*" %a in (Servers.txt) Do Logoff ID_Number /Server:%a
The above command will disconnect the same session from all the servers mentioned in the Servers.txt file.