none
get-mailboxstatistics not showing Totalitemsize when specifying e.g Value.ToKB

    Question

  • I want to use the Totalitemsize as an iteger for charts So I need to convert the xxxxxB to xxxxx (does not matter if it is in bytes, Kb, MB,.. as long as it is a number)

    What does work but then it is not a number:

    Get-MailboxStatistics -database 'ETRO2' | ft DisplayName,TotalItemSize,ItemCount

    What does not work (result is just a blank in the formatte list):

    Get-MailboxStatistics -database 'ETRO2' | Format-Table DisplayName,DatabaseName, TotalItemSize.value.ToMB

    or

    Get-MailboxStatistics -database 'ETRO2' | ft DisplayName,@{ expression={$_.TotalItemSize.Value.ToKB()}},ItemCount

    or

    Get-MailboxStatistics -database 'ETRO2' | ForEach { New-Object psobject | Add-Member -Passthru NoteProperty Displayname $_.Displayname | Add-Member -Passthru NoteProperty TotalItemSize $_.TotalItemSize.Value.ToKB() }

     

    Monday, April 19, 2010 9:59 AM

Answers

  • GREAT!

    This seems to work

    Not sure what's the difference but...hey, it works :)

    This is the command that works

    (Get-MailboxStatistics -server YourMailboxServer | select -first 1).totalitemsize.Value.ToBytes()

    or

    (Get-MailboxStatistics -server YourMailboxServer | select -first 1).totalitemsize.Value.ToMB()

    or ...

    Thanks!

    Monday, May 03, 2010 9:15 PM

All replies

  • Get-MailboxStatistics -database 'ETRO2' | Format-Table DisplayName,DatabaseName, TotalItemSize.value.ToMB

    or

    Get-MailboxStatistics -database 'ETRO2' | ft DisplayName,@{ expression={$_.TotalItemSize.Value.ToKB()}},ItemCount

    or

    Get-MailboxStatistics -database 'ETRO2' | ForEach { New-Object psobject | Add-Member -Passthru NoteProperty Displayname $_.Displayname | Add-Member -Passthru NoteProperty TotalItemSize $_.TotalItemSize.Value.ToKB() }

     

     

    Plz use it:

    Get-MailboxStatistics -database 'ETRO2' |ft DisplayName,@{label="Total Item Size";expression={$_.TotalItemSize.Value.ToKB()  } },ItemCount

     

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    • Proposed as answer by HCXpert Tuesday, November 01, 2011 3:42 PM
    Monday, April 19, 2010 10:25 AM
  • Hi,

     

    thanks for the reply but it has the same result as the other examples...it juts gives a blank for the Totalitemsize the moment you put .Value at it

     it is as if the .value is not there

    regards

    Daniel

    Monday, April 19, 2010 10:29 AM
  • Hi,

    in my case its working as u can see:

     

    [PS] C:\scripts>Get-MailboxStatistics -database 'my_db' |ft DisplayName,@{label="Size";expression={$_.TotalItemSize.Value.ToKB()  } },ItemCount

     

    DisplayName                                                                                    Size                                           ItemCount

    -----------           ----                                                                    ---------

     

    demoka                                                                                            2001                                               15

    9thMarach                                                                                         1058                                               13

    qweqwe                                                                                             0                                                    0

    user1                     0                                                                           0              

     

    As u can see for some mailboxes it is 0 possibly because they havent got an email yet.

    Regards,

     

     


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Monday, April 19, 2010 10:42 AM
  • Hi,

    Also try to run it

    Get-MailboxStatistics -database 'my_db' |ft DisplayName,@{label="Size";expression={$_.TotalItemSize } },ItemCount

     

    And tell me the output, do u still have empty values for Size property?

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Monday, April 19, 2010 10:44 AM
  • this last command works (but offcourse still with the B)

    it gives blanks the moment you put the .value at it

    Mailbox sizes are large (up to multible GB) so definitly no zero' s besides, then there would be a zero...now its is just a blank

     

    Regards

    Daniel

     

     

    Monday, April 19, 2010 10:54 AM
  • Hi,

    Can u post the exact command here which u used.

    May be you have problem with Value.ToKB() 

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Monday, April 19, 2010 10:57 AM
  • I tried all the above commands with in all cases the same result

    so

    Get-MailboxStatistics -database 'ETRO2' |ft DisplayName,@{label="Total Item Size";expression={$_.TotalItemSize.Value.ToKB()  } },ItemCount

    Get-MailboxStatistics -database 'ETRO2' | ft DisplayName,@{ expression={$_.TotalItemSize.Value.ToKB()}},ItemCount

    Get-MailboxStatistics -database 'ETRO2' | ForEach { New-Object psobject | Add-Member -Passthru NoteProperty Displayname $_.Displayname | Add-Member -Passthru NoteProperty TotalItemSize $_.TotalItemSize.Value.ToKB() }

     

     

    Monday, April 19, 2010 11:01 AM

  • I tried all the above commands with in all cases the same result

    so

    Get-MailboxStatistics -database 'ETRO2' |ft DisplayName,@{label="Total Item Size";expression={$_.TotalItemSize.Value.ToKB()  } },ItemCount

    Get-MailboxStatistics -database 'ETRO2' | ft DisplayName,@{ expression={$_.TotalItemSize.Value.ToKB()}},ItemCount

    Get-MailboxStatistics -database 'ETRO2' | ForEach { New-Object psobject | Add-Member -Passthru NoteProperty Displayname $_.Displayname | Add-Member -Passthru NoteProperty TotalItemSize $_.TotalItemSize.Value.ToKB() }

     

     

     

     

    All above commands are working on my server Exchange 2007 SP2.

    Try this with Value.ToMB() and Value.ToGB()  and see if it can make difference.

    Can u verify this behavior with some other database too?

    Also try this command:

    Get-Mailbox -database 'ETRO2' |  Get-MailboxStatistics |ft DisplayName,@{label="Total Item Size";expression={$_.TotalItemSize.Value.ToKB()  } },ItemCount

    Regards,

     


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Monday, April 19, 2010 11:11 AM
  • Get-Mailbox -database 'ETRO12' |  Get-MailboxStatistics |ft DisplayName,@{label="Total Item Size";expression={$_.TotalItemSize.Value.ToKB()  } },ItemCount

    gives:

    DisplayName                Total Item Size                            ItemCount
    -----------                ---------------                            ---------
    Kuijk Maarten                                                             37373
    Cornelis Jan p.                                                           24303
    Munteanu Adrian                                                           25382

    while

    Get-Mailbox -database 'ETRO12' |  Get-MailboxStatistics |ft DisplayName,@{label="Total Item Size";expression={$_.TotalItemSize  } },ItemCount

    gives

    DisplayName                 Total Item Size                              ItemCount
    -----------                 ---------------                              ---------
    Kuijk Maarten               6.328 GB (6,795,025,871 ...                      37373
    Cornelis Jan p.             885.3 MB (928,349,579 by...                      24303
    Munteanu Adrian             4.548 GB (4,883,498,643 ...                      25382

    Notice that I did trt on another database, same result. It's really just in the .value.ToKB/MB. very strange!

     

     

    Monday, April 19, 2010 11:17 AM
  • Are you running this from the EMS on an E2k7 server?  If not, does it produce different results if you do?

    Monday, April 19, 2010 12:42 PM
  • Are you running this from the EMS on an E2k7 server?  If not, does it produce different results if you do?

    Monday, April 19, 2010 12:42 PM
  • Hi,

    From the output it seems an Exch 2010 server, but i m not sure about the EMS thing.


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Monday, April 19, 2010 12:54 PM
  • It's indeed exchange 2010

    I'm running the commands from a remote powershell ISE but running them locally does not change a thing

     

     

    Monday, April 19, 2010 12:58 PM
  • It's indeed exchange 2010

    I'm running the commands from a remote powershell ISE but running them locally does not change a thing

     

     

    From running them locally means you have tried those command in Exchange Management Shell on exchange server or something else?

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Monday, April 19, 2010 1:00 PM
  • The object type of totalitemsize seems to have changed between E2007 and E2010.  The get-mailboxstatistics cmdlet from 2010 appears to work the same on an Exchange 2007 mailbox for all the properties except totalitemsize.

    Monday, April 19, 2010 1:03 PM
  • Hi,

    mjolinor, I have just tested it on mine Exchange 2010 RTM and its running fine, giving some numeric valuses.

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Monday, April 19, 2010 1:11 PM
  • that is correct, on the database server itself from the EMS

    Same results as running remote via ISE (on Win7 64bit)

    Server is Win2008R2

     

    Monday, April 19, 2010 1:14 PM
  • Hi,

    I thought its E2010 RTM and get the version using

    get-ExchangeServer |FL *Version

    and then came to know that mine version is

    Exchange Server 2010 RC 14.0.639.11

    It seems that this problm is with one of the later verions or Update Rollup.

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Monday, April 19, 2010 1:21 PM
  • I'm running it from my workstation (Windows 7) that has the Exchange 2010 management tools installed, and it returns "unlimited" for total itemsize on any E2007 mailbox, but returns a number and magnitude for E2010 mailboxes. 

    Running the same command from the EMS on one of the Exchange 2007 servers against an Exchange 2007 mailbox returns the expected values.

    Monday, April 19, 2010 1:23 PM
  • PS U:\> get-ExchangeServer |FL Name,*Version


    Name                : ETROEX10
    AdminDisplayVersion : Version 14.0 (Build 639.21)
    ExchangeVersion     : 0.1 (8.0.535.0)

    Name                : ETROEXBASE1
    AdminDisplayVersion : Version 14.0 (Build 639.21)
    ExchangeVersion     : 0.1 (8.0.535.0)

    Name                : ETROEXHC1
    AdminDisplayVersion : Version 14.0 (Build 639.21)
    ExchangeVersion     : 0.1 (8.0.535.0)

     

     

    Monday, April 19, 2010 1:26 PM
  • PS U:\> get-ExchangeServer |FL Name,*Version


    Name                : ETROEX10
    AdminDisplayVersion : Version 14.0 (Build 639.21)
    ExchangeVersion     : 0.1 (8.0.535.0)

    Name                : ETROEXBASE1
    AdminDisplayVersion : Version 14.0 (Build 639.21)
    ExchangeVersion     : 0.1 (8.0.535.0)

    Name                : ETROEXHC1
    AdminDisplayVersion : Version 14.0 (Build 639.21)
    ExchangeVersion     : 0.1 (8.0.535.0)

     

     

    This build shows as 

    Microsoft Exchange Server 2010 RTM  14.0.639.21

    while update rollup 3 shud be:

    Update Rollup 3 for  Exchange Server 2010  14.0.694.0

    Reference: http://social.technet.microsoft.com/wiki/contents/articles/exchange-server-and-update-rollups-builds-numbers.aspx

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Monday, April 19, 2010 1:28 PM
  • I've got a mix of 2010 and 2007. 

    All the 2010's show this AdminDisplayVersion:

    AdminDisplayVersion : Version 14.0 (Build 639.21)

    and none of them will display the totalitemsize on a 2007 mailbox.

    The Exchange 2007 servers show this AdminDisplayVersion:

    AdminDisplayVersion : Version 8.2 (Build 176.2)

    And will dislplay the byte count for totalitemsize  on both 2007 and 2010 mailboxes

    Monday, April 19, 2010 1:41 PM
  • I'll install Rollup3 this evening on the 3 servers and let you know if it made a difference. I just cleared in in WSUS

     

     

    Monday, April 19, 2010 1:45 PM
  • strange...installed rollup3 successfully (via windows update) on all 3 servers but no change!

    * Versionnumber still the same.

    * no TotalItemsize.value.Tokb()

     

    Monday, April 19, 2010 9:12 PM
  • Do you get a totalitemsize?
    Monday, April 19, 2010 9:30 PM
  • everything is exact as it was before

    PS U:\> Get-MailboxStatistics -database 'ETRO2' |fT DisplayName,@{label="Total Item Size";expression={$_.TotalItemSize.Value.ToKB()  } },ItemCount

    DisplayName                   Total Item Size                                  ItemCount
    -----------                   ---------------                                  ---------
    Vandijck Eddy                                                                      23411
    Shkerdin Gennady                                                                     228
    SystemMailbox{7bbf4437-a4f...                                                          2
    Verhelst Werner                                                                    11298
    Vounckx Roger                                                                       4163

     

    _____________________________________________________________________________________
    PS U:\> Get-MailboxStatistics -database 'ETRO2' |fT DisplayName,@{label="Total Item Size";expression={$_.TotalItemSize  } },ItemCount

    DisplayName                   Total Item Size                                  ItemCount
    -----------                   ---------------                                  ---------
    Vandijck Eddy                 1.14 GB (1,223,833,646 bytes)                        23411
    Shkerdin Gennady              32.15 MB (33,709,890 bytes)                            228
    SystemMailbox{7bbf4437-a4f... 2.063 KB (2,113 bytes)                                   2
    Verhelst Werner               1.144 GB (1,228,398,847 by...                        11298
    Vounckx Roger                 557.3 MB (584,327,001 bytes)                          4163

    Tuesday, April 20, 2010 6:13 AM
  • What does this produce?  (I know it's not what you're after, but it may help get us there).

    (Get-MailboxStatistics -database 'ETRO2' | select -first 1).totalitemsize

    (Get-MailboxStatistics -database 'ETRO2' | select -first 1).totalitemsize | gm

    Tuesday, April 20, 2010 10:03 AM
  • What does this produce?  (I know it's not what you're after, but it may help get us there).

    (Get-MailboxStatistics -database 'ETRO2' | select -first 1).totalitemsize

    (Get-MailboxStatistics -database 'ETRO2' | select -first 1).totalitemsize | gm

    I instead looked at "totalitemsize.Value | get-member"  like this

    (Get-MailboxStatistics -server ex2010 | select -first 1).totalitemsize.Value | gm

     

    shows correct output on my exch2010 RC.

     

     

    Name          MemberType

    ----          ----------

    CompareTo     Method

    Equals             Method

    GetHashCode   Method

    GetType           Method

    RoundUpToUnit Method

    ToBytes           Method

    ToGB               Method

    ToKB               Method

    ToMB          Method

    ToString      Method

    ToTB          Method

     

     

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Tuesday, April 20, 2010 10:29 AM
  • I'm not where I can test right now.  What does this produce?

    Get-MailboxStatistics -database 'ETRO2' |fT DisplayName,@{label="Total Item Size";expression={[int](iex $($_.totalitemsize.split()[0..1] -join "")) } },ItemCount

    Tuesday, April 20, 2010 10:56 AM
  • Just tested.  That doesn't work.  This seems to:

     

    Get-MailboxStatistics -database 'ETRO2' |fT DisplayName,@{label="Total Item Size";expression={[int](iex $($_.totalitemsize.tostring().split()[0..1] -join "")) } },ItemCount

    Tuesday, April 20, 2010 12:29 PM
  • Hi Dcoppee,

     

    See if the following article can be helpful:

     

    http://blogs.technet.com/evand/archive/2007/01/02/wrangling-byte-quantified-size-details-from-exchange-2007-with-powershell.aspx

     

    I also suggest you write post in the following forum to get help from script experts:

     

    http://social.technet.microsoft.com/Forums/en/ITCG/threads

     

    Thanks,

     

    Elvis

    Wednesday, April 21, 2010 7:28 AM
    Moderator
  • Hello,

     

    I'm have the same problem as Dcoppee.

    This is the outpot from a local powershell session on the exchange 2010 server:

    [PS] C:\>(Get-MailboxStatistics administrator).TotalItemSize |
     gm
    
    Name    MemberType Definition
    ----    ---------- ----------
    CompareTo  Method   int CompareTo(Microsoft.Exchange.Da...
    Equals   Method   bool Equals(System.Object other), b...
    GetHashCode Method   int GetHashCode()
    GetType   Method   type GetType()
    ToString  Method   string ToString(), string ToString(...
    IsUnlimited Property  System.Boolean IsUnlimited {get;}
    Value    Property  Microsoft.Exchange.Data.ByteQuantif...

    And this one when i connect trough the remote-powershell to the exchange server:

    PS C:\> (Get-MailboxStatistics administrator).TotalItemSize | gm
    
      TypeName: System.String
    
    Name       MemberType      Definition
    ----       ----------      ----------
    Clone      Method        System.Object Clone()
    CompareTo    Method        int CompareTo(System.Object value),
    Contains     Method        bool Contains(string value)
    CopyTo      Method        System.Void CopyTo(int sourceIndex,
    EndsWith     Method        bool EndsWith(string value), bool E
    Equals      Method        bool Equals(System.Object obj), boo
    GetEnumerator  Method        System.CharEnumerator GetEnumerator
    GetHashCode   Method        int GetHashCode()
    GetType     Method        type GetType()
    GetTypeCode   Method        System.TypeCode GetTypeCode()
    IndexOf     Method        int IndexOf(char value), int IndexO
    IndexOfAny    Method        int IndexOfAny(char[] anyOf), int I
    Insert      Method        string Insert(int startIndex, strin
    IsNormalized   Method        bool IsNormalized(), bool IsNormali
    LastIndexOf   Method        int LastIndexOf(char value), int La
    LastIndexOfAny  Method        int LastIndexOfAny(char[] anyOf), i
    Normalize    Method        string Normalize(), string Normaliz
    PadLeft     Method        string PadLeft(int totalWidth), str
    PadRight     Method        string PadRight(int totalWidth), st
    Remove      Method        string Remove(int startIndex, int c
    Replace     Method        string Replace(char oldChar, char n
    Split      Method        string[] Split(Params char[] separa
    StartsWith    Method        bool StartsWith(string value), bool
    Substring    Method        string Substring(int startIndex), s
    ToCharArray   Method        char[] ToCharArray(), char[] ToChar
    ToLower     Method        string ToLower(), string ToLower(Sy
    ToLowerInvariant Method        string ToLowerInvariant()
    ToString     Method        string ToString(), string ToString(
    ToUpper     Method        string ToUpper(), string ToUpper(Sy
    ToUpperInvariant Method        string ToUpperInvariant()
    Trim       Method        string Trim(Params char[] trimChars
    TrimEnd     Method        string TrimEnd(Params char[] trimCh
    TrimStart    Method        string TrimStart(Params char[] trim
    Chars      ParameterizedProperty char Chars(int index) {get;}
    Length      Property       System.Int32 Length {get;}

    That's the reason that i can not use *Value.ToMB()" trough a remote-session.

    What is the solution?

     

    Thank you!

    Greets Andy

    Monday, May 03, 2010 8:44 PM
  • Hi,

    And what about the result of this using both local and remote PS:

    (Get-MailboxStatistics -server YourMailboxServer | select -first 1).totalitemsize.Value | gm

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
    Monday, May 03, 2010 9:00 PM
  • GREAT!

    This seems to work

    Not sure what's the difference but...hey, it works :)

    This is the command that works

    (Get-MailboxStatistics -server YourMailboxServer | select -first 1).totalitemsize.Value.ToBytes()

    or

    (Get-MailboxStatistics -server YourMailboxServer | select -first 1).totalitemsize.Value.ToMB()

    or ...

    Thanks!

    Monday, May 03, 2010 9:15 PM
  • Hi Laeeq Qazi,

    It doesn't work for me.

     

    Local-Output:

     

    [PS] C:\>(Get-MailboxStatistics -server s-exmbx01 | select -fi
    rst 1).totalitemsize.Value | gm
    
    
     TypeName: Microsoft.Exchange.Data.ByteQuantifiedSize
    
    Name   MemberType Definition
    ----   ---------- ----------
    CompareTo  Method  int CompareTo(Microsoft.Exchange....
    Equals  Method  bool Equals(System.Object obj), b...
    GetHashCode Method  int GetHashCode()
    GetType  Method  type GetType()
    RoundUpToUnit Method  System.UInt64 RoundUpToUnit(Micro...
    ToBytes  Method  System.UInt64 ToBytes()
    ToGB   Method  System.UInt64 ToGB()
    ToKB   Method  System.UInt64 ToKB()
    ToMB   Method  System.UInt64 ToMB()
    ToString  Method  string ToString(), string ToStrin...
    ToTB   Method  System.UInt64 ToTB()

     

    Remote-Output (Error):

     

    PS C:\> (Get-MailboxStatistics -server s-exmbx01 | select -fir
    st 1).totalitemsize.Value | gm
    
    Get-Member : No object has been specified to the get-member c
    mdlet.
    At line:1 char:85
    + (Get-MailboxStatistics -server s-exmbx01 | select -first 1)
    .totalitemsize.Value | gm <<<<
     + CategoryInfo   : CloseError: (:) [Get-Member],
     InvalidOperationException
     + FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.
     PowerShell.Commands.GetMemberCommand

     

    The Property "Value" doesn't exist on a remote-connection.

     

    Best Regards,

    Andy

    Monday, May 03, 2010 9:47 PM
  • Hi Dcoppee,

    have you test it trough remote-powershell or local on a exchange-server?

    This solution only works if you were local.

     

    Greets Andy

    Wednesday, May 05, 2010 10:42 AM
  • I only tried it locally

     

    Wednesday, May 05, 2010 9:52 PM
  • I know I'm late in the game, but this worked for me just fine:

    Get-MailboxStatistics -Database <DBName> | Ft DisplayName, @{E={$_.TotalItemSize.Value.ToBytes()}; L="TotalItemSize"}, ItemCount

    I'm using local PowerShell binaries remoted to an Exchange server with Exchange 2010 SP1 UR6.

    Friday, September 14, 2012 7:31 PM
  • This is a consequence of the remoting environment.

      If you are using implicit remoting (making a session connection to an Exchange server and then importing the session into your local session), you are no longer working with native Exchange objects.  These will be deserialized objects, and there will be some loss of fidelity depth and available methods.

    Welcome to the cloud.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    Saturday, September 15, 2012 12:44 PM
  • I had exactly the same issue, but using ExchangeOnline / O365. No solution here worked for me. What was working is the following:

    $strMailboxSize = [math]::Round(($CurrentMailboxStatistic.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)

    • Proposed as answer by Bastian_W Saturday, June 02, 2018 12:46 PM
    Saturday, June 02, 2018 12:45 PM