Capturing Powershell output in C# after Pipeline.Invoke throws
Not sure if this is helpful. I am guessing you are running V1. This V2 approach doesn’t throw and prints the result: Hello World 67 errors string script = @” ‘Hello World’ ps | % { $_.name | out-string1 } “; PowerShell powerShell = PowerShell.Create(); powerShell.AddScript(script); var results = powerShell.Invoke(); foreach (var item in results) … Read more