2

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.

Albatros
  • 129
  • 1
  • 7
  • Script files should be run using the `-File` parameter: `powershell.exe -File .\shelltest.ps1`. Also, the command from your second example never returns for me. – Ansgar Wiechers Feb 19 '14 at 12:14
  • using -File gave the same response as running it as a command. The pipe the command into stdin was because I noticed that was how TeamCity did it – Albatros Feb 19 '14 at 12:58

0 Answers0