Determine if the Terminal Server console session is in use, from a command line

A couple of times lately I have been asked how to determine form a command line, if the console session is currently in use on a Windows 2003 server. One option is as as follows:  From a connected TS/RDP session you can run set sessionname This will return “console” or “RDP-Tcp#X” where X is the session numberHowever it only shows “console” if the user is at the physical console, not if they have remotely connected to the console session using mstsc /console  A better option is to use the query command:  query session This will return a list similar to: SESSIONNAME   USERNAME    ID     STATE     … Continue reading Determine if the Terminal Server console session is in use, from a command line