I have an SAP program call sapgenpse.exe.
If i excute the below command from powershell command, the output is perfect.
But if i do the same operation in powershell ISE, the output breaks abruptly.
I have an SAP program call sapgenpse.exe.
If i excute the below command from powershell command, the output is perfect.
But if i do the same operation in powershell ISE, the output breaks abruptly.
It looks like sapgenpse.exe
outputs to the stderr stream rather than to stdout.
Unfortunately, the Windows PowerShell ISE - unlike the regular console - treats and renders stderr output from external programs as errors, even though that isn't appropriate, given that stderr output cannot be assumed to (always) represent errors.
(I have no explanation for the strange format you're getting, however).
There are two workarounds:
.ToString()
method on each error record:.\sapgenpse.exe ... 2>&1 | ForEach-Object ToString
cmd.exe
and use its redirection features to redirect stderr to stdout:cmd /c '.\sapgenpse.exe ... 2>&1'
As an aside: