skip to Main Content

Get mailbox size greater than in Office 365

How to get mailbox size greater than in Office 365? You want to list mailboxes greater than a specific size. It comes in handy if you like to know which mailboxes are filling up fast. This article will show you how to get mailboxes over a certain size.

Get mailbox size greater than in Exchange on-premises

Comparison operators let you specify conditions for comparing values and finding values that match specified patterns. There are a lot of operators. The comparison operator that we will use is the operator –gt, and it stands for greater than.

List all mailboxes in Exchange on-premises greater than 50 GB. Again, this is in Exchange on-premises.

[PS] C:\>Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Where-Object {$_.TotalItemSize -gt "50GB"} | Sort-Object TotalItemSize -Descending | Select-Object DisplayName, ItemCount, TotalItemSize

DisplayName ItemCount TotalItemSize
----------- --------- -------------
Info           122916 59.07 GB (63,423,330,124 bytes)

Let’s run the same cmdlet in Exchange Online PowerShell. Before doing that, we have to connect to Exchange Online with PowerShell.

Connect to Exchange Online PowerShell V2

Connect to Exchange Online PowerShell V2. After that, check if you did connect to Exchange Online. An excellent way is to run the Get-EXOMailbox cmdlet and list five mailboxes.

Make use of the EXO cmdlets when connected to Exchange Online. It will retrieve the data faster, and we recommend using it.
PS C:\> Connect-ExchangeOnline -UserPrincipalName admin@exoip.com


PS C:\> Get-EXOMailbox -ResultSize 5 | Select-Object DisplayName

DisplayName
-----------
Amanda Morgan
Jonathan Fisher
Piers Rees
Benetiz Anees
Larson Tevin

Get mailbox size greater than in Office 365 error

Let’s use the same cmdlet as we did in Exchange on-premises, this time in Exchange Online – Office 365. After pressing Enter, the output is giving us the following errors.

  • Error: Cannot convert value to type
  • Error: Operation is not valid due to the current state of the object.
PS C:\>Get-EXOMailbox -ResultSize Unlimited | Get-EXOMailboxStatistics | Where-Object {$_.TotalItemSize -gt "50GB"} | Sort-Object TotalItemSize -Descending | Select-Object DisplayName, ItemCount, TotalItemSize

Could not compare "1.491 MB (1,563,034 bytes)" to "50GB". Error: "Cannot convert value "50GB" to type
"Microsoft.Exchange.Management.RestApiClient.Unlimited`1[Microsoft.Exchange.Management.RestApiClient.ByteQuantifiedSize]". Error: "Operation is not valid due to the current state of the object.""
At line:1 char:81
+ ... MailboxStatistics | Where-Object {$_.TotalItemSize -gt "50GB"} | Sort ...
+                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : ComparisonFailure

Could not compare "46.8 MB (49,073,930 bytes)" to "50GB". Error: "Cannot convert value "50GB" to type
"Microsoft.Exchange.Management.RestApiClient.Unlimited`1[Microsoft.Exchange.Management.RestApiClient.ByteQuantifiedSize]". Error: "Operation is not valid due to the current state of the object.""
At line:1 char:81
+ ... MailboxStatistics | Where-Object {$_.TotalItemSize -gt "50GB"} | Sort ...
+                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : ComparisonFailure

What is the solution to the errors and how to get mailbox size greater than in Office 365?

Get mailbox size greater than in Office 365

Use the cmdlet to get all mailboxes in Office 365 with a size of greater than 50 GB. Adjust the size to your needs.

[PS] C:\>Get-EXOMailbox -ResultSize Unlimited | Get-EXOMailboxStatistics | Where-Object {[int64]($PSItem.TotalItemSize.Value -replace '.+\(|bytes\)') -gt "50GB"} | Sort-Object TotalItemSize -Descending | Select-Object DisplayName, ItemCount, TotalItemSize

DisplayName    ItemCount TotalItemSize
-----------    --------- -------------
HR                100695 71.84 GB (77,135,813,741 bytes)
Sales              56826 66.25 GB (71,135,800,362 bytes)
James Paterson    187451 64.34 GB (69,088,700,819 bytes)
Info              236743 50.62 GB (54,354,792,583 bytes)

If you only want to get shared mailboxes greater than 50 GB.

[PS] C:\>Get-EXOMailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited | Get-EXOMailboxStatistics | Where-Object {[int64]($PSItem.TotalItemSize.Value -replace '.+\(|bytes\)') -gt "50GB"} | Sort-Object TotalItemSize -Descending | Select-Object DisplayName, ItemCount, TotalItemSize

DisplayName    ItemCount TotalItemSize
-----------    --------- -------------
HR                100695 71.84 GB (77,135,813,741 bytes)
Sales              56826 66.25 GB (71,135,800,362 bytes)
Info              236743 50.62 GB (54,354,792,583 bytes)

Mailbox size greater than the size set is successfully shown. Did it work for you?

Keep reading: Move mailbox to Exchange Online with PowerShell »

Conclusion

In this article, you learned how to get mailbox size greater than in Office 365. Connect to Exchange Online PowerShell and run the cmdlet, as shown in the article. The comparison operator greater than is great to use.

Did you enjoy this article? You may also like Outlook prompts for password after migration to Office 365. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top