In my previous position, I sometimes had to
grant temporary access to remote servers to
the administrators of other departments in
that company. Sometimes these administrators
forgot to log off the remote server after
they completed their tasks, thus locking out
other administrators
when the Windows
Server 2003
Terminal Services
session limit had
been reached. Usually
the offending administrators were out to lunch or had left
for the day. This always seemed to happen
when there was a problem that needed
immediate attention on that server. Typically,
I had used Terminal Services Manager to log
off the administrator. However, there were
times when that wasn’t an option because
the remote server I needed to access was the
one running Terminal Services Manager.
When I was searching the Internet for a
solution to this problem, I came across a
discussion of the PsExec tool in the Windows
Power Tools column “PsExec” (July
2004, InstantDoc ID 42919). PsExec lets you
launch interactive command-prompt sessions
and run programs on remote systems
without having to install client software on
those systems. This tool looked promising,
so I downloaded the latest version from the
Microsoft TechNet website (technet.micro
soft.com/en-us/sysinternals/bb897553.aspx).
I decided to try PsExec in a test environment.
I ran a command that followed the
syntax
C:\psexec \\ServerName
-u Domain\UserID cmd
where ServerName was the name of the
remote server I needed to access and Domain UserID was the username I wanted to
use to log on to that server. The cmd argument
told PsExec to launch an interactive
command-prompt session on that server.
After I entered my password, the remote
server’s command-prompt window appeared.
I then ran the Query Session command:
Query Session
The output showed the user IDs of the
administrators who were connected to the
server. I was then able to use the following
Logoff commands with the administrators’
IDs to log off those administrators:
Logoff 2
Logoff 3
Afterward, I reran the Query Session command
to see if those administrators were
logged off. The Logoff commands were
successful.
Because this was a test environment, I
knew that the administrators I logged off
weren’t running any important tasks on the
remote server. However, in a production
environment, you need to make sure that
the administrator you’re about to log off
isn’t running an important task. You can use
the Tasklist command to check which tasks
are running and who is running them. Assuming
you’re still logged on to the remote
server, you can use the command
Tasklist /v /fi "STATUS eq running"
From that point on, I used PsExec to log
off administrators on all remote servers.
Using Terminal Services Manager to access
a remote server takes a couple of minutes,
whereas using PsExec takes only a couple
of seconds. As this practical usage of PsExec
demonstrates, sometimes you need to
keep an open mind and think beyond
GUIs.
—Tim Bolton, Microsoft infrastructure technician,
Lightedge Consulting Services
End of Article


Curt Spanburgh
SCG October 03, 2008 (Article Rating: