How can I list the logged in users with PowerShell?

To retrieve local sessions: qwinsta

To retrieve remote sessions: qwinsta /server:servername


Try following one line to find a list of logged on users.

query user /server:$SERVER