I am implementing my own PowerShell node and I need to read stdout and stderr from a PowerShell script. The problem is that I don't get stdout when I convert the object returned by calling the pipeline to a string. However, when I add the out-string cmdlet to the pipeline, it works fine. Is there any way to get stdout and stderror without using "out-string"?
this.currentPowerShell.AddScript(cmd);
Collection<PSObject> results = this.currentPowerShell.Invoke();
foreach (PSObject obj in results)
{
Console.WriteLine(obj.ToString());
}
When I use the code above, I only get a partial stdout.
source
share