Managing Terminal Services from the Command Line
In addition to the tools in Terminal Services Manager, there are quite a few command-line tools for working with Terminal Services. These commands can be divided into two categories:
Controlling user sessions
Gathering Terminal Services Information
Several commands are available for gathering Terminal Services information from the command line including the following:
QUERY PROCESS [* | ProcessId | UserName | SessionName | /ID:SessionId | Program-Name] [/Server:ServerName]—Displays information about processes being run in Terminal Services sessions on the server
QUERY SESSION [SessionName | UserName | SessionId] [/Server:ServerName]—Displays information about Terminal Services sessions ...