How can I get warning output from the PowerShell cmdlet programmatically in version 1.0?

I am using PowerShell v1.0 (this is a requirement that I cannot use 2.0), and I am having problems capturing the cmdlet output programmatically in the warning stream.

In Powershell 2.0, it's easy:

var powerShell = PowerShell.Create();
powerShell.AddCommand(someCommand);
powerShell.Invoke();

foreach (var warning in powerShell.Streams.Warning) { ... }

However, the System.Management.Automation.PowerShell class does not exist in PowerShell version 1, and existing classes do not allow access to the warning stream. In addition, warning thread information does not fit into the standard output of the cmdlet.

Thank! Sam

+3
source share
1 answer

( ), . -, , V1.0.

+4

Source: https://habr.com/ru/post/1735428/


All Articles