Have you ever had a request to display the Top X Mailbox Users in an organization? In my lab, I wanted to see which accounts were the highest with all my testing and pumping data in to test certain things and putting together a quick script helped me achieve this. Below is a snippet of what was shown from running the script.

You can run this straight from the Exchange Management Shell or you can add the PS module and run it from a PowerShell window:

Display the top 10 largest mailboxes in PowerShell

In the script, I do specify the first 10 objects using the “Select-Object -First 10” option a the end of the script and you can modify this if you want to show, 50, 100 or whatever number is required. Feel free to modify it as you need to, perhaps you want to export the information to a CSV file and you can add this in at the end.

I also include a top section to connect to Exchange if you are doing this from a machine with no Management tools on, below is the full script:

# Connect to the Exchange server (you may need to modify the server name)
$exchangeServer = "YourExchangeServerName"
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$exchangeServer/PowerShell/ -Authentication Kerberos
Import-PSSession $session -DisableNameChecking -AllowClobber -WarningAction SilentlyContinue

# Get the largest mailboxes
$largestMailboxes = Get-Mailbox | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName, TotalItemSize

# Display the results
Write-Host "Top 10 Largest Mailboxes:"
$largestMailboxes | Select-Object -First 10 | Format-Table -AutoSize

# Disconnect from the Exchange server
Remove-PSSession $session

This small script may help you get that info quickly for management if they request it for reporting purposes or just want to know where things are.

Hope it helps

    wpChatIcon

    Discover more from Everything-PowerShell

    Subscribe now to keep reading and get access to the full archive.

    Continue reading