Tuesday, September 3, 2013

Exchange 2010/2013 - Get-MailboxStatistics TotalItemSize in Numeric Format

To get a list of all mailboxes and their sizes, the following command produces this information.

Get-Mailbox | Get-MailboxStatistics |  select-object DisplayName,TotalItemSize

However the data outputted by this command is not in a format which can be used with script, it is not numeric as shown in the following screenshot.


To get the data for TotalItemSize just as a number such as KB, MB, GB etc, use the following commands:

{$_.TotalItemSize.Value.ToKB()}
{$_.TotalItemSize.Value.ToMB()}
{$_.TotalItemSize.Value.ToGB()}

For example:

Get-Mailbox | Get-MailboxStatistics |  select-object DisplayName, {$_.TotalItemSize.Value.ToMB()}

This will ensure the data returned is in a format which you can use for scripting.

6 comments:

  1. Thank you, sir. Helped me out a lot.

    ReplyDelete
  2. [PS] C:\>(Get-MailboxStatistics crawforda).totalitemsize
    231.9 MB (243,185,054 bytes)
    [PS] C:\>(Get-MailboxStatistics crawforda).totalitemsize |gm


    TypeName: System.String

    Name MemberType Definition
    ---- ---------- ----------
    Clone Method System.Object Clone()
    CompareTo Method int CompareTo(System.Object value), int CompareTo(string strB)
    Contains Method bool Contains(string value)
    CopyTo Method System.Void CopyTo(int sourceIndex, char[] destination, int destinationIndex,...
    EndsWith Method bool EndsWith(string value), bool EndsWith(string value, System.StringCompari...
    Equals Method bool Equals(System.Object obj), bool Equals(string value), bool Equals(string...
    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 IndexOf(char value, int startIndex), int IndexOf...
    IndexOfAny Method int IndexOfAny(char[] anyOf), int IndexOfAny(char[] anyOf, int startIndex), i...
    Insert Method string Insert(int startIndex, string value)
    IsNormalized Method bool IsNormalized(), bool IsNormalized(System.Text.NormalizationForm normaliz...
    LastIndexOf Method int LastIndexOf(char value), int LastIndexOf(char value, int startIndex), int...
    LastIndexOfAny Method int LastIndexOfAny(char[] anyOf), int LastIndexOfAny(char[] anyOf, int startI...
    Normalize Method string Normalize(), string Normalize(System.Text.NormalizationForm normalizat...
    PadLeft Method string PadLeft(int totalWidth), string PadLeft(int totalWidth, char paddingChar)
    PadRight Method string PadRight(int totalWidth), string PadRight(int totalWidth, char padding...
    Remove Method string Remove(int startIndex, int count), string Remove(int startIndex)
    Replace Method string Replace(char oldChar, char newChar), string Replace(string oldValue, s...
    Split Method string[] Split(Params char[] separator), string[] Split(char[] separator, int...
    StartsWith Method bool StartsWith(string value), bool StartsWith(string value, System.StringCom...
    Substring Method string Substring(int startIndex), string Substring(int startIndex, int length)
    ToCharArray Method char[] ToCharArray(), char[] ToCharArray(int startIndex, int length)
    ToLower Method string ToLower(), string ToLower(System.Globalization.CultureInfo culture)
    ToLowerInvariant Method string ToLowerInvariant()
    ToString Method string ToString(), string ToString(System.IFormatProvider provider)
    ToUpper Method string ToUpper(), string ToUpper(System.Globalization.CultureInfo culture)
    ToUpperInvariant Method string ToUpperInvariant()
    Trim Method string Trim(Params char[] trimChars), string Trim()
    TrimEnd Method string TrimEnd(Params char[] trimChars)
    TrimStart Method string TrimStart(Params char[] trimChars)
    Chars ParameterizedProperty char Chars(int index) {get;}
    Length Property System.Int32 Length {get;}


    I find no Value property. How can I get to(MB) without value property?

    ReplyDelete
  3. As lover view journalists, we have now commonly brought to you anyone with low-priced possibilities when getting were only available in intricate timepieces, through possibilities this way. However the likeness with the holiest regarding holies not to mention primarily a person from a identified along with reliable watch, seems to have nonetheless really been unachievable to the majority of. Made from several different devices to include the two-hand automatic to somewhat of a watch not to mention offered in different call along with band alternatives, this specific cutting edge variety in total is really a spectacular in addition to desired starting by preceding choices. Everyone will definitely always be sampling straight into several other versions while in the arranged soon plus are all impressively cost, however, mainly at this moment we should concentration on that gem on the collection, plus demonstrate the key reason why simply because foot orthotics clock buffs you need to certainly come to be focus. We tend to likewise talk with pieces, and even discussion regarding model place and pay attention to easy methods to maintain the pieces clean up. This watch has been your visible watchmaker inside 18th 100 years and his / her company name came out with back pocket wrist watches and wrist watches on the early on the twentieth one. A brand name have been resurrected as being a advanced expensive brand name together with everyone just found the opportunity to examine several running watches from other group. When you are looking at an excellent conclusion check out that is not from your very own common suspects, many are really worth an additional start looking. Any time clearly there was ever before a quartz check out which need lusted just for, it is the pieces. When its name suggests, these kind of devices depend upon new fahsion impulses to discover his or her specific location so are then simply in a position to connect with them to enable you to develop the precise time regardless of where you can be www.refinedwatch.com. But, you will find that assume that all the trademark can be diluting all those things the particular check out signifies for it has the pursuit of increased advertise present. Celebrity endorsements, unnecessary sponsorships and even a pile of unveil occasions took priority finished honest horological option, certain fight. Is actually the valid? This handles both of these opposition vistas in the old-school-style discussion. It is the conclude of your calendar year plus some from you happen to be eyeing a different wristwatch might be mainly because you are feeling a tad unique from the first deposit bonuses you have got merely stored, or possibly you want to observe immediately after aquiring a fantastic month. No matter ones reasons could be, always bear in mind all these key phrases with information out of your looks after. Using an important style in which efficiently utilizes the actual dial and also the lug length, the only would wear bigger when compared to chances are you will assume. May very well 7 within wrists and even eyes which are which is used to viewing wristwatches in great hand, though the follow thinks excellent as well as sub-40mm size continues the devices from sensation fashionable and too big for their develop. You will get typically the notion the fact that 38mm is not purely preferred even on a impulse, but alternatively the fact that the different size for some on their virtually all well-known wrist watches had been the main topic of quite a lot of awareness in addition to preparation. Your different watches cling thus accurately to the insular meaning about design and style them to often find a way to be present away from tendencies or possibly model.

    ReplyDelete
  4. If your boss (like mine) wants you to get a mailboxsize report you're going to run into trouble sorting. What I did to overcome that is use a regular expression and replace the totalitemsize value to a whole number then convert it later on after it's sorted.

    [string]$MailboxSize = (get-mailboxStatistics $Name).totalItemsize.value
    [int64]$MailboxSize = ($MailboxSize -replace "(^.*?\()|\D")


    Honestly I don't get why micro soft created the display like this for this value. So very annoying.

    ReplyDelete
  5. Can this code be converted into alphanumeric? Where is the source code of this program? android app development

    ReplyDelete