Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a powerhsell script( to get the mailbox size of an exchange 2010 mailbox), and I am executing this script in my C# code. The following is the code I have used for that
powershell.AddScript(strQuery);
Collection<psobject> objPS = powershell.Invoke();

I tried to get the properties from this result using following code...

foreach (PSObject results in objPS)
{
PSMemberInfoCollection<pspropertyinfo> obj = results.Properties;
foreach (PSPropertyInfo a in obj)
{
writelog(a.Name + " | " + a.Value);
}
}


The result which I got is as follows....

PSComputerName | win-8t4iub1nrog.exchange.mydomain.com
RunspaceId | 48e93449-e5c0-49ab-b31e-18f00c9ce1a0
PSShowComputerName | True
Length | 47


In this result set there is no property called TotalItemSize, but I am sure that the result contains TotalItemSize, as I have printed the result.tostring() in another test program. that result is as follows

@{TotalItemSize=2.224 KB (2,277 bytes); PSComputerName=win-8t4iub1nrog.exchange.mjs.com; RunspaceId=66e1f258-327f-44a1-bfb2-3e929b971d22; PSShowComputerName=True}

So, Can someone tell me how to extract the TotalItemSize from this result set.

Regards
Sebastian
Posted
Updated 27-Jan-13 18:28pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900