You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some commands can return error and some output.
Example: Get-Process chrome,Tuupertunut returns an error about Tuupertunut and a list of chrome processes.
PowerShellLibJava throws PowerShellExecutionException and doesn't provide access to the list of chrome processes
Yes, the library has been designed so that it throws an error if anything was printed to stderr. This works for most use cases but sometimes it could be useful to get output from stdout even if there is an error. However it is very unlikely that I would ever update this library to support that use case.
You can circumvent this limitation by wrapping the PowerShell code in PowerShell's try-catch and handling the errors yourself, or you could edit the library code to give you access to stdout output.
Activity
Tuupertunut commentedon Feb 7, 2023
Yes, the library has been designed so that it throws an error if anything was printed to stderr. This works for most use cases but sometimes it could be useful to get output from stdout even if there is an error. However it is very unlikely that I would ever update this library to support that use case.
You can circumvent this limitation by wrapping the PowerShell code in PowerShell's try-catch and handling the errors yourself, or you could edit the library code to give you access to stdout output.
vlad8x8 commentedon Feb 7, 2023
Hi @Tuupertunut . Thank you for reply.
I decided to use basic java
Runtime.getRuntime().exec("powershell.exe " + command)without libraries