query session
Displays information about sessions on a Remote Desktop Session Host server. The list includes information not only about active sessions but also about other sessions that the server runs.
Note
To find out what's new in the latest version, see What's New in Remote Desktop Services in Windows Server.
Syntax
query session [<sessionname> | <username> | <sessionID>] [/server:<servername>] [/mode] [/flow] [/connect] [/counter]
Parameters
Parameter | Description |
---|---|
<sessionname> |
Specifies the name of the session that you want to query. |
<username> |
Specifies the name of the user whose sessions you want to query. |
<sessionID> |
Specifies the ID of the session that you want to query. |
/server:<servername> |
Identifies the rd Session Host server to query. The default is the current server. |
/mode | Displays current line settings. |
/flow | Displays current flow-control settings. |
/connect | Displays current connect settings. |
/counter | Displays current counters information, including the total number of sessions created, disconnected, and reconnected. |
/? | Displays help at the command prompt. |
Remarks
A user can always query the session to which the user is currently logged on. To query other sessions, the user must have special access permission.
If you don't specify a session using the <username>, <sessionname>, or sessionID parameters, this query will display information about all active sessions in the system.
When query session returns information, a greater than
(>)
symbol is displayed before the current session. For example:C:\>query session SESSIONNAME USERNAME ID STATE TYPE DEVICE console Administrator1 0 active wdcon >rdp-tcp#1 User1 1 active wdtshare rdp-tcp 2 listen wdtshare 4 idle 5 idle
Where:
- SESSIONNAME specifies the name assigned to the session.
- USERNAME indicates the user name of the user connected to the session.
- STATE provides information about the current state of the session.
- TYPE indicates the session type.
- DEVICE, which isn't present for the console or network-connected sessions, is the device name assigned to the session.
- Any sessions in which the initial state is configured as DISABLED won't show up in the query session list until they're enabled.
Examples
To display information about all active sessions on server Server2, type:
query session /server:Server2
To display information about active session modeM02, type:
query session modeM02