Tuesday, 6 March 2012

How to log off remote desktop users from a remote machine ?

When you try to log on to a  remote server on emergency to perform some task , it may throw an error "The terminal server has exceeded the maximum number of allowed connection". In many servers you may not have the rights to log on with /console or /admin option. I have faced this issue many times and the only option is to get the help from infrastructure team to log off users from the server.

I was searching for a solution for this and found  an option to log off the remote desktop users from  another machine (in the same domain) through command line. The first step to achieve is to list the current  log on session on the remote computer. For that we can use following command from the command prompt. Replace the with your server IP address.

C:\>quser /SERVER:

This will list the current log on session. Please find below screenshot. I have removed the IP address and log in name from the screenshot. You can see the session ID 0,1 and 2 for three available sessions. This is the ID which we will be using in our next step to log off user.

To log off session listed in the previous step, use the following command.Here I am trying to log off the session 0

C:\> logoff / 0 /V 

Now you will be able to do the remote desktop to the server.