Share via


Query session

 

Applies To: Windows Vista, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012

Displays information about sessions on a Remote Desktop Session Host (RD Session Host) server.

The list includes information not only about active sessions but also about other sessions that the server runs.

For examples of how to use this command, see Examples.

Note

In Windows Server 2008 R2, Terminal Services was renamed Remote Desktop Services. To find out what's new in the latest version, see What’s New in Remote Desktop Services in Windows Server 2012 in the Windows Server TechNet Library.

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 Query Information special access permission.

  • If you do not specify a session by using <SessionName>, <UserName>, or <SessionID>, query session displays information about all active sessions in the system.

  • When query session returns information, a greater than (>) symbol is displayed before the current session. Following is sample output for query session:

    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
    

    The greater than (>) symbol indicates the current session. 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 is not present for the console or network-connected sessions, is the device name assigned to the session. The comment following session information is from the session profile. Any sessions in which the initial state is configured as DISABLED do not show up in the query session list until they are 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
    

Additional references

Command-Line Syntax Key

Query

Remote Desktop Services (Terminal Services) Command Reference