Get-MailboxStatistics for all users

Zach Summers 1 Reputation point
2021-11-04T15:53:40.907+00:00

I need to run Get-MailboxStatistics to get the Calendar item count for all users in my domain. I'd prefer to not have to manually type in 150+ names to do this.

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
6,098 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
4,628 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 62,156 Reputation points Microsoft MVP
    2021-11-04T16:59:35.58+00:00

    Get-MailboxStatistics does not expose any folder-level details, nor the number of Calendar items. For that, you need Get-MailboxFolderStatistics. Here's a sample:

    Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited | % { Get-MailboxFolderStatistics $_.UserPrincipalName -FolderScope Calendar | ? {$_.FolderType -eq "Calendar"} | select Identity,ItemsInFolder,FolderSize } | Export-CSV -nti blabla.csv
    

  2. KyleXu-MSFT 25,616 Reputation points
    2021-11-05T08:29:30.447+00:00

    @Zach Summers

    You could change it into a script:

    $Mailboxes = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited  
    $data = @()  
      
    foreach($mailbox in $mailboxes){  
        $data+=Get-MailboxFolderStatistics $mailbox.UserPrincipalName -FolderScope Calendar| where{$_.FolderType -eq "Calendar"} | select Identity,FolderSize  
    }  
    $data | Export-Csv C:\Users\demo\Desktop\2.csv -NoTypeInformation  
    

    If you still get an error about it, you could add a delay in this script:
    146812-qa-kyle-16-27-04.png

    Please note: Do not run this script multiple times in a short period of time. Otherwise you will be restricted by Exchange online.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.