Stack,
How do you distinguish with PSObjects are created by WriteObject() WriteWarning() WriteError()?
Starting with this:
psCmd = PowerShell.Create();
Runspace = RunspaceFactory.CreateRunspace();
Runspace.Open();
psCmd.Runspace = Runspace;
psCmd.AddCommand(cmdletName);
Collection<PSObject> results = null;
results = psCmd.Invoke();
The results variable contains the all the PSObjects piped out the commandlet. How do you identify PSObjects that were created by WriteObject() WriteError() WriteWarning() by the commandlet?
I want add code that achieves the following:
foreach(psObj in results) {
if ( IsWarning(psObj) )
{
// Turn on yellow flashing lights
}
else if ( IsError(psObj) )
{
// Turn on red flashing lights
}
else
{
// Write to ticker-tape
}
}