Forum Discussion

bala official's avatar
bala official
Copper Contributor
Feb 14, 2020

Error while fetching MessageTrace data using PowerShell

I tried to fetch the Message Trace data for the last 7 days through Power Shell. After getting 3 days of data, we face 

 

Cmdlet-InvalidExpressionException. (Page result exceeds maximum threshold. CATEGORY: InvalidArgument.)

 

We tried to fetch the data multiple times but we keep facing the error. We couldn't fetch data for more than three days. We get approximately 1.4 million records.

 

We used the below script to fetch the data,

 

$Page = 1;do{$CurrMessages = Get-MessageTrace -PageSize 5000 -Page $Page -StartDate (Get-Date).addDays(-7) -EndDate (Get-Date);$Page++;$CurrMessages}until ($CurrMessages -eq $null);

 

 

Resources