I have total of 11 years of IT experience with Application development, Database Development and Database Administration. I have worked with different version of SQL server from 7.0 to 2008.Started my carrier as VB ,VC++ and database developer in a banking sector for implementing their core banking solution. Currently working as Database Administrator with wide knowledge in performance tuning, high availability solution, troubleshooting and server monitoring. This blog is my humble attempt to share my knowledge and what I learned from my day to day work.
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 xx.xx.xx.xxx with your server IP address.
C:\>quser /SERVER: xx.xx.xx.xxx
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 /SERVER:xx.xx.xx.xxx 0 /V
Now you will be able to do the remote desktop to the server.