Is it possible to speedup Get-Mailboxstatistics for exchange online? RRS feed

  • Question

  • i need to run get-mailbox statistics for 4000 users, i m thinking is there a way to speedup get_mailboxstatistics

    I have read in forum to use Get_mailboxstatistics -server but i think we cannot use it for exchange online atleast as we don't know the servers where the mailboxes are.

    Can i use the below cmdlet 

    $MailboxStat =Invoke-Command  -scriptblock { Get-MailboxStatistics $mailbox.UserPrincipalName |  select-object TotalItemSize,DisplayName}

    I just need TotalItemSize and display name for each mailbox users . I don't know weather this will really speedup 



    Tuesday, June 27, 2017 12:44 PM

All replies

  • Yes, using Invoke-Command and reducing the output to only specific properties can certainly help, but for specific cmdlets only. If you run it with Get-Mailbox, it will have much bigger effect compared to Get-MailboxStatistics, as the latter only runs for one user at a time.

    In general it's best to get this data directly from the reports in the O365 Admin Center or the corresponding APIs. PowerShell based methods will require you to loop over each mailbox, so they will inevitably take lot longer to complete. Still, if you decide to do it via PowerShell, some other hints to optimize the code can be found here:

    Tuesday, June 27, 2017 7:50 PM
  • yes , i too read this blog before posting this question

    One doubt i have in the cmdlet

    Get-MailboxStatistics $mailbox.UserPrincipalName |  select-object TotalItemSize,DisplayName

    in this cmdlet aren't we doing more operation than just Get-MailboxStatistics?

    since there is a pipe operator output of Get-MailboxStatistics first return all the properties and then we are filtering to select only 2 properties. Wont it take more time than just doing Get-MailboxStatistics itself?

    Wednesday, June 28, 2017 9:08 PM
  • No, it actually helps a bit as it forces only the desired output to be returned, instead of having all the object properties travel over the net. But again, as the Get-MailboxStatistics cmdlet runs against one mailbox at a time, you will not see much benefit from invoking it directly. When you get the full list of all mailboxes via Get-Mailbox for example, the difference will be much noticeable.

    I would still advice you to use the reporting API instead, this information is readily available in the Mailbox usage report.

    Thursday, June 29, 2017 7:16 AM