Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

3 Answers 3

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

share|improve this answer
    
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. –  Brent Pabst 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. –  Brent Pabst 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:

SETLOCAL  
SET FilePath=%1%  
SET UserNameToSearch=%2%  
FOR /F %%i IN (%FilePath%) DO query user %UserNameToSearch% /server:%%i  
ENDLOCAL  
share|improve this answer
    
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

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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