powershell.exe does not return term signal to parent process

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of Vern Anderson Vern Anderson 3 years, 6 months ago.

  • Author
    Posts
  • #11837
    Profile photo of Vern Anderson
    Vern Anderson
    Participant

    Hello, I'm looking for a way to call powershell.exe from a PSEXEC "like" process but it hangs or doesn't appear to be sending the errorlevel that the parent proces is waiting for.

    http://www.leeholmes.com/blog/2007/10/02/using-powershell-and-psexec-to-invoke-expressions-on-remote-computers

    I tried piping "echo." to it as suggested in the above article but then the command doesn't run. When it hangs it does execute my command it just never tells the parent process it completed. Are there any special commands to force that errorlevel or to force it to send the exit code to the parent process?

    Here is the command that is the "payload"

    Get-Service -DisplayName DSM*  | Start-Service

    I'm doing

    powershell.exe -Command {Get-Service -DisplayName DSM*  | Start-Service}

    I know it executes because I am logged on locally and I can see the services do start but it never closes the powershell.exe process nor does the parent process ever close causing my API to log it as an error and cuases 2 processes running on the server that never close.

    -VERN

  • #11844
    Profile photo of Richard Siddaway
    Richard Siddaway
    Moderator

    Is there a reason you aren't using remoting?

  • #11859
    Profile photo of Vern Anderson
    Vern Anderson
    Participant

    Yes politics is the only answer I can give right now 🙁

    But remoting is not an option everything is triggered by an RBA system and Orchestration system that is not Microsoft.

  • #11876
    Profile photo of Vern Anderson
    Vern Anderson
    Participant

    I still need help with this problem. Even if I compile the script to an EXE it still hangs with this PSEXEC like process. Remoting is not a possibility right now.

You must be logged in to reply to this topic.