how to fetch warning or error messages printed by powershell cmdletfrom C#

S

shiv

Hi, I have written a small application to fetch mailboxes and public
folder in C# using powershell cmdlets.
But if mailbox store is disabled then powershell cmdlet "get-
mailboxstatistics" will show some warning messages in yellow colour.
But how do I capture it my code ?

Here is the sample code which I am using
----------------------
Collection<PSObject> results = ri.Invoke("Get-MailboxStatistics");
foreach (PSObject mo in results)
{
PSPropertyInfo prop =
(PSPropertyInfo)mo.Properties["DisplayName"];
}
--------------------

With this code is there any way I can fetch errors or warning messages
which are thrown at cmdlet output ?

Regards,
Shivaraj
 
J

Jeff Johnson

Hi, I have written a small application to fetch mailboxes and public
folder in C# using powershell cmdlets.

You'll probably have better luck asking in a group dedicated to PowerShell.
I can't remember the last time I saw a PowerShell-related question asked in
this group, let alone answered.
 
Top