Detecting who is logged in via command line

QWINSTA is a neat utility that debuted with Windows VISTA and Windows Server 2008. This will allow you to see who is logged into the computer. This can be run both locally and remotely. It give you the session type, for example, is it a remote session or a console session. It also gives you the name(s) of who is logged in and the session state, like active or disconnected for example. Although this command works in PowerShell, it is really a command level application and has limited functionality in PowerShell scripts. Below are a few examples of syntax for QWINSTA.