How to get the mailbox statistics data for more than 70,000 shared mailboxes in bulk

85 Views Asked by At

I'm using cloud environment.

I initially tried to get the total mailbox count to execute the script of retreiving mailbox statistics in batches using below code... But it gives me a server side error.

Help me to solve this error. Is there any alternative ways to get mailbox statistics data. Because Get-Mailbox throws error each time I run it.

PS C:\WINDOWS\system32> ***Get-Mailbox -ResultSize unlimited -RecipientTypeDetails SharedMailbox | Measure-Object***
Write-ErrorMessage : A server side error has occurred because of which the operation could not be completed. Please try again after some time. 
If the problem still persists, please reach out to MS support.
At C:\Users\Afasdf\AppData\Local\Temp\tmpEXO_caglfdam.ak2\tmpEXO_caglfdam.ak2.psm1:1191 char:13
             Write-ErrorMessage $ErrorObject
            ~~~
     CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
     FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-ErrorMessage
 

***Count    : 65000
Average  : 
Sum      : 
Maximum  : 
Minimum  : 
Property :***

I'm expecting to return the count of the total shared mailboxes in my tenant, so that I am able to batch the process of retrieving the mailbox statistics data using for loops.

1

There are 1 best solutions below

0
Mike Anthony On

Your command is correct. I've not worked in such a large org before so haven't run into this issue, but Microsoft have a write-up on running cmdlets for large numbers of users - specifically, try execute on the server:

Invoke-Command -Session (Get-PSSession) -ScriptBlock { Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited | Select-Object Name,Alias } -HideComputerName

If you do this sort of thing often, RobustCloudCommand looks pretty cool.