"Data in the command exceeded the maximum permitted by the session configuration" error when you run the Get-Mailbox -ResultSize Unlimited command in Exchange Online

PROBLEM

When you use the remote Exchange PowerShell command Get-Mailbox -ResultSize Unlimited to retrieve information about Exchange Online mailboxes in your organization, you receive an error message that resembles the following:
[ClientAccessServer=XXXXXXXXXCA014,BackEndServer=XXXXXXmb294.namprd05.prod.outlook.com,RequestId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,TimeStamp=<Date><Time>] The data in the command exceeded the maximum permitted by the session configuration. The allowed maximum is 500MB. Change the input, use a different session configuration, or change the "PSMaximumReceivedObjectSizeMB" and "PSMaximumReceivedDataSizePerCommandMB" properties of the session configuration on the remote computer

CAUSE

This issue occurs when the process times out as it tries to retrieve a large volume of data in one session. This issue may occur when you try to retrieve mailbox information from a very large organization.

WORKAROUND

To work around this issue, run the command to execute on the server, and then add a pause between each command to prevent throttling.

Step 1: Retrieve the list of objects from the server

Use the Invoke-Command cmdlet to execute the commands from the server. For example:
$mailboxes = Invoke-Command -Session (Get-PSSession) -ScriptBlock {Get-Mailbox -ResultSize Unlimited | Select-Object -Property Identity,DisplayName} 

Step 2: Add a pause between each command

Use the Start-Sleep cmdlet to add a pause between each object that's being processed. For example:
foreach($m in $mailboxes) {Get-MailboxPermission $m.Identity.ToString() | Where { ($_.AccessRights -eq "FullAccess") -and ($_.IsInherited -eq $False) -and -not ($_.User -like "NT AUTHORITY\SELF")}; Start-Sleep -Milliseconds 500} 

MORE INFORMATION

For more information, see the following Microsoft TechNet resources:
Still need help? Go to Microsoft Community.
属性

文章 ID:2922668 - 上次审阅时间:2016年12月29日 - 修订版本: 1

反馈