I know that Invoke-MyCmd
throws an error and writes a message to standard error.
Let's say it's one line that invokes a Java program like this:
function Invoke-MyCmd
{
java Error
}
Error.java just prints an error message and exits:
import java.io.*;
public class Error {
public static void main(String[] args) {
System.err.println("Hello, error!");
}
}
I'm invoking Invoke-MyCmd from C# like so:
PowerShell ps = PowerShell.Create();
.
.
.
ps.AddCommand("Invoke-MyCmd");
Collection<PSObject> output = ps.Invoke();
The error text, I'm assuming because it comes from Java and not directly from Invoke-MyCmd
, doesn't show up in ps.Streams.Error
. I'm wondering if there's another way to read that error output from C#.