Forum Discussion

qotd00's avatar
qotd00
Copper Contributor
Feb 11, 2025

Broken Exchange API - ExplorerActivityData

Hello everyone,

 

I'v been trying to get the Export-ActivityExplorerData API to work but with no luck.

Sometimes the script stop at 100 results , sometimes 5000 results. The script stay the same.


My theory is that the API call encountered a wrong / corrupted watermark and it crash the next query.

Did anyone ever face this bug ? Do i have to assume that this API is broken ?

The script to test:

$START = (Get-Date).AddDays(-1).Date
$END = (Get-Date).Date.AddSeconds(-1)

$Query = Export-ActivityExplorerData -StartTime $START -EndTime $END -Filter1  @("Activity", "LabelApplied", "LabelChanged", "LabelRemoved") -PageSize 5000 -OutputFormat csv
$EXTRACT = $Query.ResultData
while ($Query.LastPage -ne $true) {
    $WaterMark = $Query.WaterMark
    $Query = Export-ActivityExplorerData -StartTime $START -EndTime $END -Filter1  @("Activity", "LabelApplied", "LabelChanged", "LabelRemoved") -PageSize 5000 -OutputFormat csv -PageCookie $WaterMark
    $EXTRACT += $Query.ResultData
}


Regards,
Q.

  • Dean_Gross's avatar
    Dean_Gross
    Silver Contributor

    qotd00we are seeing the same error, its seems to be random. Have you been able to find out any more information?

  • qotd00's avatar
    qotd00
    Copper Contributor

    As i didn't find the edit button, here is the error output:

    Write-ErrorMessage : |Microsoft.Exchange.Hygiene.DataInsights.Common.ElasticsearchDataProviderPermanentException|One or more errors occurred.
    Microsoft.Exchange.Hygiene.DataInsights.Common.ElasticsearchDataProviderBadOrInvalidRequestException: Invalid scroll cookie. Exception message: Newtonsoft.Json.JsonReaderException: Error reading JObject from JsonReader. Current JsonReader item is not an object: 
    Integer. Path '', line 1, position 3.
       at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
       at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
       at Microsoft.Exchange.Hygiene.DataInsights.ElasticsearchDataProvider.ParseScrollPaginationCookie(String watermark, DateTime& scrollCookieExpiryTime, Boolean& isExpiredCookie, String& scrollID, String& endPointMachine, String& hashedQueryFilterString, String& 
    errorMessage)
       at Microsoft.Exchange.Hygiene.DataInsights.ElasticsearchDataProvider.ParseFilter(QueryFilter filter, SortBy[] sortBy, Int32 pageSize)
       at Microsoft.Exchange.Hygiene.DataInsights.ElasticsearchDataProvider.ParseFilter(QueryFilter filter, SortBy[] sortBy, Int32 pageSize)
     
    Au caractère C:\Users\\AppData\Local\Temp\tmpEXO_2pgp2pr2.xcy\tmpEXO_2pgp2pr2.xcy.psm1:1189 : 13
    +             Write-ErrorMessage $ErrorObject
    +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidResult : (:) [Export-ActivityExplorerData], ElasticsearchDa...manentException
        + FullyQualifiedErrorId : [TimeStamp=Tue, 11 Feb 2025 14:58:13 GMT],Write-ErrorMessage

     

Resources