question

lmastalerz avatar image
0 Votes"
lmastalerz asked KyleXu-MSFT edited

Monitor PowerShell Exchange online limits

Hi,

I'm trying to use PowerShell to extract large amount of data from Exchange Online.
I'm using Get-MessageTrace cmdlet.
As expected I started hitting limits and getting errors like this one:

This operation exceeds the throttling budget for policy part 'LocalTime',
policy value '6000000', Budget type: 'PowerShell'. Suggested backoff time
299912 ms.

Whilst the error is not a surprise I'd like to make sure I'm protected against this type of error and in order to do this and to scale the script dynamically I'd like to be able to monitor usage against existing quotas and suspend/resume the process when it approaches the limit.
Is there a way to check current consumption of resources along with their limits?

There's also a bonus question - is there a better was to extract email metadata from Exchange Online?
(I'm interested in just a basic information like sender, recipient, subject, timestamp, etc.)

Many Thanks,
Lukasz


windows-server-powershelloffice-exchange-server-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

michev avatar image
0 Votes"
michev answered

You cannot, the only way is to capture the warnings and backoff for a while. Here's a script/module that shows you how to handle this: https://github.com/Canthv0/RobustCloudCommand/blob/master/RobustCloudCommand.psm1

As for other methods, I'm afraid you're stuck with PowerShell. You can try some of the newer cmdlets such as Get-MailDetailATPReport:

 Get-MailDetailATPReport -EventType "Message passed" -StartDate "01 May 2021" -EndDate "15 May 2021" -PageSize 5 -DataSource RealtimePipeline -Direction inbound | fl
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.