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
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
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
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.