Exploring Terminal Server's most useful command-line utilities
Windows NT Server 4.0, Terminal Server Edition has been available for almost a year, and administrators are fitting the OS into networks throughout the NT world. Microsoft designed Terminal Server to attract Citrix WinFrame users who are looking for an NT 4.0 thin-client product. Terminal Server has succeeded in interesting many WinFrame customers, and it has brought many new administrators into the multiuser-NT fold. (For more information about Terminal Server and WinFrame, see "Related Articles in Windows NT Magazine," page 78.)
Terminal Server includes all of NT's graphical administrative tools. NT's point-and-click utilities, including User Manager, Server Manager, and NT Explorer, make learning to administer Terminal Server systems a breeze. These GUI tools are wonderful for new administrators and small projects, but administrators of large networks need command-line alternatives.
Veteran NT administrators know that one of NT's primary weaknesses is its lack of command-line alternatives to GUI utilities. Administering an NT network from the command line is impossible without Microsoft Windows NT Server 4.0 Resource Kit tools such as Addusers, Rmtshare, and Xcacls. (For information about these utilities, see "AddUsers," May 1998; Reader to Reader, February 1998; and "XCACLS," March 1998.) WinFrame has always offered better command-line tools than NT has offered, and Terminal Server includes much of WinFrame's command-line functionality. As far as I can tell, Microsoft hasn't documented Terminal Server's command-line tools, but as I've hacked around on my Terminal Server systems, I've found some useful utilities. Because I use RDP on my network, I'll cover the Terminal Server commands that work with both RDP and WinFrame's Independent Computing Architecture (ICA) protocol.
See Whether a User Is Logged On
The Query User tool gives you information about users' connections to a Terminal Server system. Want to know whether a user with the NT username janesmith is attached to the server Shipboard? Open a command prompt on any Terminal Server machine in Shipboard's domain, and type
query user janesmith /server:shipboard
If Jane Smith isn't logged on to Shipboard, Terminal Server will respond with the answer "No User exists for janesmith." If she is logged on to Shipboard, you'll get information about her. You'll see her username, her Terminal Server session name (a string such as rdp-TCP#1), her session ID (a number that identifies the session), the number of minutes her session has been idle, and what time she logged on. The session ID that Query User provides is important; you need it to run some of Terminal Server's other command-line utilities.
Query User's syntax looks like
query user [<identifier>] [/server:<server name>]
The identifier variable can be a user's username, session name, or session ID. Any one of these three identifiers gives Query User enough information to find a particular user session. If you type
query user
without an identifier, you'll get a list of the users who are logged on to your server. (You can use an alternative Terminal Server utility named Qwinsta to list all of a server's sessionsincluding not only active user sessions but other sessions that the system runs for its own purposes.)
Without the /server: parameter, Query User gives you information about the people logged on to the server that you're sitting at. To query a different server, add /server: and the name of the server you want to query. For example, to remotely request a list of the people attached to a server named Pungo, you type
query user /server:pungo
I haven't found a way to ask Terminal Server to search every server in a group for a particular user; telling Terminal Server "See whether janesmith is logged on to any of this domain's Terminal Server systems" seems impossible.