Hi,
Please try using the below command and see if that gives the required output.
[Int] $intInbox = $intSent = 0
Get-Mailbox -ResultSize Unlimited | Get-MailboxFolderStatistics -FolderScope Inbox | Where {$_.Name -match “Inbox”} | Select ItemsinFolderandSubfolders | ForEach {$intInbox++}
Get-Mailbox -ResultSize Unlimited | Get-MailboxFolderStatistics -FolderScope "Sent Items" | Where {$_.Name -match “Sent Items”} | Select ItemsinFolderandSubfolders | ForEach {$intSent++}
Write-Host "Organization Inbox Items: ",$intInbox
Write-Host "Organization Sent Items: ",$intSent
Or alternatively, you can export the inbox items and sent items of all mailboxes into a CSV and use Excel to get the overall count which might be simpler.
Get-Mailbox -ResultSize Unlimited | Get-MailboxFolderStatistics -FolderScope Inbox | Where {$_.Name -match “Inbox”} | Sort-Object DisplayName, ItemsinFolderandSubfolders -Descending | Export-csv c:\temp\MailboxItemCountInbox.csv
Get-Mailbox -ResultSize Unlimited | Get-MailboxFolderStatistics -FolderScope "Sent Items" | Where {$_.Name -match “Sent Items”} | Sort-Object DisplayName, ItemsinFolderandSubfolders -Descending | Export-csv c:\temp\MailboxItemCountSentItems.csv
If the above suggestion helps, please click on "Accept Answer" and upvote it. Thanks for understanding.