powershell.exe does not return term signal to parent process

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.

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

Is there a reason you aren’t using remoting?

Yes politics is the only answer I can give right now :frowning:

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

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.