Powershell: the output doesn't really come out

I am researching on behalf of someone trying to use powershell with one of our products. Our product can execute a command to perform an operation, and most folk will call an .exe that works fine. One user calls some powershell but with this method:

powershell -version 2.0 -NonInteractive -ExecutionPolicy ByPass -file ($ScriptsFolder)p4_commit.ps1 {"($Message)" ($Files)}

      

What happens is that it never comes out, so our software sits and waits forever. The script ends up with a simple "exit 0", and the line just before that is the debug output that appears if we cancel the process from the outside, so it gets to the end of the script OK (and yes, the script works fine otherwise).

If I remove the exit command and replace it with a powershell kill session:

Stop-Process -Id $PID

      

Then it ends, but of course the exit code is not 0 and we are rolling back the changes, so this is not a good fit to solve the problem.

Otherwise, back to 'exit 0', I see that powershell.exe with the passed parameters is still showing up in the task manager; so it's not that he leaves, and we don't collect it, he just doesn't leave.

Alas, I'm not much of a powershell expert, so the question boils down to "What will stop the game from quitting?"

+3


source to share


1 answer


OK, confirmed, fixed the command to call powershell.exe on startup / wait. I have no idea why (this would definitely go all the way to the end of the script, as if I changed the output to something random I would get an error).



However, the problem is resolved ...

+2


source







All Articles