Ever wondered how many items all the mailboxes in your Exchange environment currently have? Getting a weekly count of these, together with the total mailbox size, might be useful so you get a trend on your environment’s growth.
For a single mailbox, you can simply use the following cmdlet:
Get-MailboxStatistics user1 | SelectItemCount
Or if you want to get a count per database for example:
Get-MailboxStatistics –Database MDB1 | ForEach {$totalItems+=$_.ItemCount}
$totalItems
If you want for every single mailbox in your environment, you can use the following cmdlet:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | SelectItemCount | ForEach {$totalItems+=$_.ItemCount}