locked
Psexec & PowerShell RRS feed

  • Question

  • If I execute following batch, it won’t exec next line until I press enter…

    psexec \\XXX -p *** -u ** PowerShell -NoLogo -Command "&{ Get-EventLog -List }"

    psexec \\XXX -p *** -u ** PowerShell -NoLogo -Command "&{ Get-EventLog -List }"

    psexec \\XXX -p *** -u ** PowerShell -NoLogo -Command "&{ Get-EventLog -List }"

     

    And this one doesn’t need “anykey”

    psexec \\XXX -p *** -u ** cmd /c dir c:\

    psexec \\XXX -p *** -u ** cmd /c dir c:\

    psexec \\XXX -p *** -u ** cmd /c dir c:\

     

    Am I missing something obvious? ;-(

    Thursday, May 27, 2010 3:09 AM

Answers

All replies

  • What OS are you running this from?  I ran the top group via batch file on a Vista box and it ran without waiting for me to hit Enter to proceed to the next line.

    Also, have you tried adding the -accepteula into the string just in case it may be waiting for you to accept the agreement?

    psexec  -accepteula \\XXX -p *** -u ** PowerShell -NoLogo -Command "&{ Get-EventLog -List }"

    Monday, July 19, 2010 8:43 PM
  • Have you had a chance to look at this and verify the OS and if you have used the -accepteula switch?
    Wednesday, July 28, 2010 3:52 AM
  • Is this still an open issue for you? If it is, please let us know and we will help you out as best as we can.  Also, have you tried running PSExec as I described in my initial post to you?
    Sunday, August 29, 2010 9:38 PM
  • Just tried executing from 2008 R2 to 2008 R2 or 2003 R2 same result exactly

    Before (in May) executed from 2003 R2 to 2008 R2 or 2003 R2, no difference

     

    Changing “psexec”  to “psexec  -accepteula” changes nothing

     

    PowerShell -NoLogo -Command "&{ 2 + 2 }"

    PowerShell -NoLogo -Command { 2 + 2 }

    PowerShell "2 + 2"

    all need “anykey”

     

    PowerShell -NoLogo –Help

    doesn’t need “anykey”

     

    Somehow “-Command” key (even implicit) makes "psexec + PowerShell" wait for keyboard tap.

    Just wondering if somebody can reproduce this behavior…

    PsExec v1.98

    Monday, August 30, 2010 12:42 AM
  • Looks like it is a known issue:

    http://forum.sysinternals.com/topic10823.html

    Use Lee Holmes work around solution to prevent PSExec from hanging when trying to run powershell with it.

    http://www.leeholmes.com/blog/UsingPowerShellAndPsExecToInvokeExpressionsOnRemoteComputers.aspx

    • Marked as answer by IamMred Tuesday, October 26, 2010 3:26 AM
    Monday, August 30, 2010 3:26 AM
  • Ok. Thanks a lot for the link. I read whole article and apparently I need to redo a lot…

    Still wondering if there is any easier solution to make last line work?

     

    cmd /c "echo . | PowerShell -NoLogo -Command { 2 + 2 }"

    cmd /c "echo . | PowerShell -NoLogo -Command &{ 2 + 2 }"

     

    1st on print 2 + 2

    2nd gives error…

     

    • Proposed as answer by Xsakorov Tuesday, March 19, 2013 11:43 AM
    Monday, August 30, 2010 8:04 PM
  • cmd /c echo . ^ | PowerShell -NoLogo -Command "&{ 2 + 2 }"

    output: 4

    • Proposed as answer by Xsakorov Tuesday, March 19, 2013 11:44 AM
    Tuesday, March 19, 2013 11:44 AM