Windows Tip: How To Remotely Logoff Users via Command Line Tools

Here is a message I got the other day that prevented me from logging into a server remotely.

The Terminal Server has exceeded the maximum number of connections.

Windows Servers allow the maximum of two concurrent remote sessions at any given time unless you have Terminal Services enabled. For any Windows Server 2008 or later, it seems to be ok because you will have the option kicking any active users right at the login screen but for any Server 2003, exceeding that will give you the above message and will just stop you right there. In order to get in that server remotely, you can use the following tip to remotely log off any active or disconnected sessions first and try logging in again.

First of all, use the command line QUser, short for Query Users, to get a list of login sessions on the remote computer.

QUser /server:ComputerName

Replace the ComputerName with the actual remote computer name.

Command Line - QUser

To remotely log off any users on the list, use the command line Logoff with the remote session ID you collected from QUser command.

Logoff sessionID /server:ComputerName

Command Line - logoff

Don’t be scared off by the switch name “server”. It works not only on Windows Server 2003 and above but also Windows desktop platforms as well. If you want to log a remote user off a Windows 10 or Windows 7 computer, simply run the same commands described above, as long as you know the remote computer name and have the user account that has the local admin rights on the remote computer.

Original Article