Remotely signoff users from Remote Desktop session

Lets say you want to see how is connected to a remote computer (using Remote Desktop) and you want to disconnect that user remotely? For example, I want to connect to a remote computer for administrative purposes and can’t due to too many existing connections.

In pervious versions of Windows Server (2003/2008) we had a tool called ‘Remote Desktop Services Manager’I used this tool a lot! to see who is logged on, to disconnect sessions and etc… In Windows Server 2012 Microsoft has decided to drop the tool. Lately, I found the best way to do that – using command line.

Two tools are involved – QUSER and LOGOFF.

Using QUSER you can see who is connected to a remote computer:


quser /server:SERVERNAME

Just change the server name parameter and you will be able to see who is logged on to that server:


USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
UserA rdp-tcp#93 1 Active 5 11/9/2015 2:48 PM
UserB rdp-tcp#89 2 Active 4+00:53 10/27/2015 8:07 AM
UserC 3 Disc 5+12:52 11/10/2015 9:18 PM

Here you can see that UserB session name is rap-tcp#89 and session id is 2 and he’s been idle for 4 days. Lets kick that user away, we need his session!


logoff 2 /server:SERVERNAME

Using the logoff command I’m able to perform a logoff for a specific session and server.

Now I’m able to connect 🙂

 

What do you think about this post?