I work in an enterprise environment with hundreds upon hundreds of Windows servers (all in a single AD domain), both locally and in other countries. I'm often required to log into an RDP session on various servers and, sometimes, I may forget to log off before closing the window. Obviously, this is not ideal, and I'd like to know if anybody knows a way to scan a domain for remote sessions running from my (or another user's, for that matter) account. Thanks!


Why not just set GPOs for the server for session idle timeouts so if you forget about one it automatically logs you off after a certain amount of inactive time. Set it for a couple of hours or more. Worst case you forget when you leave for the day and the servers automatically disconnect you that night.

If you want to do this yourself and actually go look for these suckers you could easily script it out, here's the MSFT CLI docs for TS

  • Sometimes it is necessary to leave sessions open for days... large data transfers, etc. Otherwise, that would be a great solution.
    – Rob C.
    Sep 18 '12 at 20:52
  • Why aren't you using UNC file paths for data transfers instead of through the RDP shell. That would take longer than the built in network file copy process. Sep 18 '12 at 21:50
  • All this being said, we use a product at work called Remote Desktop Manager from Devolutions that allows you to view connections and sessions, assuming users have connected through the software tool. It does have some other benefits too though. Sep 18 '12 at 21:51
  • When migrating data from non-domain member servers following acquisitions, I generally map a network drive (which requires domain creds) and kick off a Robocopy. Since the servers are usually not physically accessible to me and ILO or DRAC haven't been configured, I can't do it from the console, so I need to leave the session running for the duration of the migration. Fun, huh?
    – Rob C.
    Sep 19 '12 at 17:42

This should do it:

for /f %i in (servers.txt) do query user jsmith /server:%i  

You can eliminate jsmith if you want to display all usernames.

If used in a cmd script, double the percent sign:

SET FilePath=%1%  
SET UserNameToSearch=%2%  
FOR /F %%i IN (%FilePath%) DO query user %UserNameToSearch% /server:%%i  
  • This method worked rather well, once I pulled a list of servers! Thanks, Greg!
    – Rob C.
    Oct 4 '12 at 16:14

Have you tried the MMC Remote Desktop Management snapin? Microsoft also offers Remote Desktop Connection Manager

Should be easy to check what connections are open and if inactive

  • Hi, thanks for the response. Unless I'm using these incorrectly, they don't seem to be able to do what I need which is, essentially, scan all the servers in my domain, and report back to me which ones have an open session with my username on it.
    – Rob C.
    Sep 18 '12 at 18:12
  • Hmmm I have the MMC snapin configured so that all my servers show in the snapin. It is then a simple matter to see what servers have open sessions.
    – Dave M
    Sep 18 '12 at 18:35
  • We literally have hundreds of servers. :^)
    – Rob C.
    Sep 18 '12 at 20:51

IF you have only RDP into the servers through Microsoft's Remote Desktop Connection Manager and saved all the servers that you have logged into... then there is an option to find the all your Disconnected sessions through List Sessions option. Select each server and right click on it and select list sessions tab option. It will open up a new window and show the list of all users sessions that are connected to the server(Active, Disconnected etc). Find your session and logoff from the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.