Aug 08 2019 02:08 AM - edited Aug 08 2019 02:14 AM
I'm running this command in Exchange Online PowerShell to Check permission of a User on all mailboxes in the Organization (For Auditing Purpose) -
1. Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission -User Ankit (Fails )
2. Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission -User Ankit | Export-csv (Fails )
3. $Mailboxes = Get-Mailbox -ResultSize Unlimited
$mailboxes | Get-Mailboxpermission -user Ankit | Export-csv (Fails
4. $mailboxes |Get-MailboxPermission -User Ankit ; Start-Sleep -Milliseconds 500| Export-Csv
All of them fail with Error - Sending data to a remote command failed with the following error message: The data in the command exceeded the maximum size that is
allowed by the session configuration. The allowed maximum is 500 MB. Change the input, use a different session configuration, or
change the "PSMaximumReceivedObjectSizeMB" and "PSMaximumReceivedDataSizePerCommandMB" properties of the session configuration on
the remote computer. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OperationStopped: (outlook.office365.com:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : JobFailure
+ PSComputerName : outlook.office365.com
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. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OperationStopped: (outlook.office365.com:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : JobFailure
+ PSComputerName : outlook.office365.com
Aug 08 2019 04:11 AM
Aug 08 2019 10:45 AM
Those one-liners are convenient, but they don't really work in scenarios where you have thousands and thousands of users, as you've already noted. Get the list of user mailboxes, store it in a variable, then do a loop over each. If that fails as well, minimize the amount of data transferred by fetching just the bare minimum of properties you need, instead of the 200+ that Get-Mailbox returns. This can be done by using the method detailed here: https://techcommunity.microsoft.com/t5/Exchange-Team-Blog/Running-PowerShell-cmdlets-for-large-numbe...