Identify if a server is currently accessed via Remote Desktop Connection

remote desktop

For instance I have a server that is used by 4 people and there is only one account in that server. We know that when someone is already accessing it and another user accessed the server, the current user will be disconnected.

Is there any way to identify if a server is currently accessed via Remote Desktop Connection to prevent unwanted interruption of the active user.

Best Answer

This applies to the following OS: Windows Server 2008, Windows Server 2008 R2, Windows Server 2012 and Windows Vista. Try this command:

query session [<SessionName> | <UserName> | <SessionID>] [/server:<ServerName>] [/mode] [/flow] [/connect] [/counter]

This should give output like the following:

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

Source

Hope this helps.