I have a problem with qwinsta only returning headers when executed using PsExec.
A minimal test case for this is to create a file "shelltest.ps1", containing just a single command (the last parameter to the qwista is the username but I get the same problem without it)
PSExec \\***.***.***.*** -u **** -p **** -accepteula qwinsta ****
When I excute this using file as input I get the right behavior
C:\>powershell.exe -Command .\shelltest.ps1
PsExec v2.0 - Execute processes remotely
Copyright (C) 2001-2013 Mark Russinovich
Sysinternals - www.sysinternals.com
SESSIONNAME USERNAME ID STATE TYPE DEVICE
rdp-tcp#0 **** 2 Active rdpwd
qwinsta exited on ***.***.***.*** with error code 0.
but when I pipe in the command, I suddenly get only the header
C:\>powershell.exe -Command - < shelltest.ps1
PsExec v2.0 - Execute processes remotely
Copyright (C) 2001-2013 Mark Russinovich
Sysinternals - www.sysinternals.com
SESSIONNAME USERNAME ID STATE TYPE DEVICE
qwinsta exited on ***.***.***.*** with error code 0.
The real problem is a bit more complex, but an explanation on why this happens is hopefully sufficient enough to solve it.