We have a problem at work when people are remotely adminstering Windows servers with Remote Desktop technology (aka Terminal Services). Instead of logging off, they can leave sessions open but just disconnected. So how do we get round this? (Windows Servers have a connection limit of two users, unless its a properly configured Terminal Server).
What I do is use Sysinternals PsExec utility along with some command line tools to logoff those users and enable access.
PsExec allows a user to run a remote command on a server, so what we do is spawn off a command shell remotely…
- Download psexec.exe from http://live.sysinternals.com
- Open a cmd.exe (Start > Run….. cmd.exe)
- Cd to where you downloaded psexec.exe and type
- You should now effectively have a cmd.exe running on the remote server (type hostname and press enter, will tell you “where” you’re cmd.exe is running).
psexec \\<servername> -u <user> -p <password> cmd.exe
There is a couple of commands we can run now
Query Session – Shows us which users are connected to which terminal server sessions
Query Process – Shows us which processes are being run by which users
Reset <Sessionid> – This will reset the disconnected sessions (you can get the sessionid from query session.