Get Top Mailboxes By Size in Powershell
As the problem was related to only Database named “DB3” so we only want report for that specific database.
Get-mailboxdatabase -identity DB3 | Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName,TotalItemSize -First 100 | Export-CSV Top50Mboxes-Db3.csvExplanation:Get-mailboxdatabase -identity DB3 this command gets the data from the Database DB3
Get-Mailbox -ResultSize Unlimited this command brings all of the mailboxes in this database
Get-MailboxStatistics this command brings the statistics about all the mailboxes in DB3
Sort-Object TotalItemSize -Descending this commands sorts the mailboxes by size (Largest first)
Select-Object DisplayName,TotalItemSize -First 50 now we can select the columns that we want to display and -first 50 gives us the top 50 mailboxes in DB3 by size.
Export-CSV D:Top50Mboxes-Db3.csv and finally we export the output to the csv on D: drive