PowerShell: list total item count and item size in mb per database
$dbs = Get-MailboxDatabase
foreach ($db in $dbs)
{
$out = new-object psobject
$dbstats = Get-MailboxStatistics -database $db
$totaldbsize = 0
$totalmbcount = 0
foreach ($dbstat in $dbstats)
{
$totalmbcount = $totalmbcount + 1
$totaldbsize = $totaldbsize + $dbstat.TotalItemSize.Value.ToMB()
}
$out | add-member noteproperty Identity $db.Identity
$out | add-member noteproperty MailboxCount $totalmbcount
$out | add-member noteproperty SizeMB $totaldbsize
Write-Output $out
}
Which results as output:
Identity MailboxCount SizeMB
——– ———— —-
SERVERStorageGroupDB1 2324 54323
SERVERStorageGroupDB2 6767 24345
SERVERStorageGroupDB3 968 9324