
When you have a large environment and you are running a command such as Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | select ....
you might have seen this error:
1 2 |
Sending data to a remote command failed with the following error message: The total data received from the remote client exceeded the allowed maximum. The allowed maximum is 524288000 |
There are a couple of solutions or workarounds.
- One solution could be to split the command and run it against each database instead and then combine the result.
- Another option is to use a ForEach loop instead of piping the command, this seems to work in most cases as well.
- Or create a new- PSSessionConfiguration on your remote server
Open a PowerShell window as Administrator
1 |
Register-PSSessionConfiguration -Name CustomDataLimits #Name could be anything you want |
Then you need to configure the values: MaximumReceivedDataSizePerCommandMB
and MaximumReceivedObjectSizeMB
1 |
Set-PSSessionConfiguration -Name CustomDataLimits -MaximumReceivedDataSizePerCommandMB 500 -MaximumReceivedObjectSizeMB 500 |
Then create a new session with the custom PSSessionConfiguration:
1 |
$Session = New-PSSession -ComputerName servername -ConfigurationName CustomDataLimits |
Make sure that you create the Custom PSSessionConfiguration on the server you are connecting to otherwise you’ll get an error saying something like
1 |
The WS-Management service cannot process the request. |
I hope this was informative. For questions or comments you can always give a reaction in the comment section or contact me:
I ran into this exact issue setting Exchange public folder permissions. Instead of piping
get-publicfolder …. -recurse | Add-PublicFolderClientPermission
This worked for me:
get-publicfolder …. -recurse | foreach {….}