find user disconnection time in RDP session Windows server 2012

Naigel picture Naigel · Aug 24, 2015 · Viewed 16.2k times · Source

We have a pool of develop machines where developers log in through RDP and usually they doesn't log off but just disconnect. As local administrator I can force the log off but I would like to check when the user disconnected.

From task manager I can see only the user name and its status

enter image description here

Is there a way to discover when the user disconnected using task manager, powershell, cmd or whatever?

Answer

LT- picture LT- · Apr 11, 2017

You can use windows command query user UserName /server:ServerName or you can just enter query user /server:ServerName to find out all active or disconnected sessions.

Below is the sample output, I have blurred out my info for privacy:

enter image description here

I have also created a PowerShell script to do this task automatically, here is the link Powershell to find out disconnected RDP session and log off at the same time