Identify if a server is currently accessed via Remote Desktop Connection

Solution 1:

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.