Microsoft 365

Microsoft 365: List User Mailboxes sorted by Mailbox Size

In this blog post I will show you how you can get a list of your Microsoft 365 Exchange Online recipients sorted by size. I am a documentation geek so it’s not a surprise that I always striving to have a good overview of user mailbox sizes and storage usage.

Connect to Exchange Online

First of all we need to connect to Exchange Online. Hit the keys and enter the following lines to connect to your tenant.


$Session = New-PSSession -ConfigurationName Microsoft.Exchange `
-ConnectionUri https://outlook.office365.com/powershell-liveid/ `
-Credential (Get-Credential) -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking 

How do you know that worked? You should see this screen:

Anmerkung 2020-04-04 092638

Retrieve a list of Microsoft 365 Mailboxes sorted by Mailbox Size

Next, run the code below to get a list of all user mailboxes sorted by size in descending order.


Get-Mailbox -RecipientTypeDetails UserMailBox -ResultSize Unlimited |
Get-MailboxStatistics |
Where-Object {!$_.DisconnectDate} |
Sort-Object -Property TotalItemSize -Descending |
Select-Object DisplayName,ItemCount,TotalItemSize,LastLogonTime

Anmerkung 2020-04-06 093925.png

Fine. That’s it. Mission accomplished.

See also

Microsoft 365: Show Mailboxes that have Auto-Reply enabled

Microsoft 365: Add User Accounts and Mailboxes with PowerShell

8 replies »

  1. #Install-Module PowerShellGet -Force
    #Install-Module –Name ExchangeOnlineManagement
    Connect-ExchangeOnline

    Get-EXOMailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited | Get-EXOMailboxStatistics | Select-Object Displayname, TotalItemSize, MailboxGuid | Sort-Object TotalItemSize -Descending

    Like

  2. Hi Patriick, thanks for sharing. when i am trying to authentication, i am getting access denied. I have global administrator access.

    “New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : Access is denied. For more
    information, see the about_Remote_Troubleshooting Help topic.
    At line:1 char:12
    + $Session = New-PSSession -ConfigurationName Microsoft.Exchange `
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OpenError: (System.Manageme….RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed

    Like

  3. Hi.

    For a big organisation, is there a way to stop this from timing out? Also, how would you include the online archive as an extra column?

    Many thanks

    Like

Leave a Reply to Andy Thomas Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.