Toll Free: +1 888 900 4529 |   Toll Free: +44 800 088 5522

Getting Into Mailbox Size In PowerShell Explained With Illustration

wpedbtopst | July 29th, 2015 | general

Windows PowerShell is deployed by Microsoft. PowerShell is a Framework for the automation of task and its configuration. The tasks are performed in commandlets and it consists of command-line shell as well as scripting language.

There are four named commands in PowerShell:

  • Cmdlets
  • PowerShell functions
  • PowerShell scripts
  • Standalone programs that are executable

The PowerShell provides many features such as; manipulation of objects, command-based navigation, extensible interface, gets mailbox size, contains design, cmdlets for performing system administration, etc.

PowerShell Developers:

The developers are;

  • Windows PowerShell SDK
  • Windows PowerShell Programmer’s Guide

They allow the developers to have their own PowerShell modules, functions, etc.

Now, PowerShell has become a big hand for the Exchange Server. The Get-MailboxReport.ps1 script of PowerShell enables to generate reports of the server mailbox statistics. Let us see how the size of mailbox of the Exchange server is seen in PowerShell. In PowerShell, we will be able to see the information according to our needs or wishes.

How to View Mailbox Size and Other Details?

The Get-MailboxStatistics cmdlet gets the user the details of the mailbox on the server such as; size of mails, mail counts, last accessed time, etc.

Syntax is:

Get- MailboxStatistics {username}

The user can get the details according to the requirement; you need to mention it properly. To get the name, size and total count the following syntax is to be followed.


Get-MailboxStatistics {username} |ft DisplayName, TotalItemSize, ItemCount

If we want, we can view the report in text file using the syntax as following;

mailboxstatistics command

How To Filter And Sort Out The Mailbox?


For filtering out only the items specified to the ‘mailbox’, user needs to follow up;

Get -MailboxStatistics | where {$_.ObjectClass_eq “Mailbox”

To Sort Out:

Always an ordered view gives a good look. There are commands for the reordering of the item lists seen. There are two ways to clear the busted items; descending and ascending.

Let’s see how descending works.


Get – MailboxStatistics| Sort –Object TotalItemSize – Descending

Same syntax is also used for ascending, just need to change Descending to Ascending.

Change Size format:

We can convert the size to MB if necessary and for that need to do a replacing of ‘TotalItemSize’ to


After customizing the view is;

There are many other options of customizing. The syntaxes are;

  • @{label=”Total Size(MB)”;expression={$_.TotalItemSize.Value.ToMB()}

Customize using:


  • @{label=”Items”;expression={$_.ItemCount}}


  • @{label=”Storage Limit”;expression={$_.StorageLimitStatus}}


  • @{label=”User”;expression={$_.DisplayName}}

All these above mentioned commands can be grouped together and we can obtain the result; helps in saving the time. The one line is:

Get-MailboxStatistics | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | ft @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}},@{label=”Items”;expression={$_.ItemCount}},@{label=”Storage Limit”;expression={$_.StorageLimitStatus}} -auto


There are many ways by which the PowerShell helps the users of Exchange Server. Using the PowerShell, the sum, minimum, average, etc. of the ‘TotalItemSize’ can be calculated as well. However, not all those details are mentioned here in the article but, an overall view of the usage of PowerShell is mentioned and hope will be helpful.

The following two tabs change content below.