Click here to Skip to main content
11,805,035 members (66,633 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# PowerShell
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
Collection objPS = powershell.Invoke();

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

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

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

PSComputerName |
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);; RunspaceId=66e1f258-327f-44a1-bfb2-3e929b971d22; PSShowComputerName=True}

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

Posted 17-Jan-13 22:45pm
Edited 27-Jan-13 18:28pm

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

  Print Answers RSS
0 OriginalGriff 305
1 Sergey Alexandrovich Kryukov 268
2 CPallini 210
3 Richard Deeming 190
4 CHill60 150
0 OriginalGriff 3,255
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100