Azure AD Connect stopped syncing to Azure AD. Looking in Azure AD Connect Synchronization Service…
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.
Table of contents
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.
Note: 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.
Thanks!!! Absolute legend.
Nice Job! This was helpful. Thx [int64]($PSItem.TotalItemSize.Value -replace ‘.+\(|bytes\)’)