A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.
To automate the download of Message Trace logs for more than 10,000,000 records per day, you can try the following suggestions:
- Considering that the entries far exceed the limit, you need to split the query into smaller time intervals to ensure that this limit is not exceeded.
- For larger datasets, you can use Start-HistoricalSearch and Get-HistoricalSearch to search for message data.
- Create a PowerShell script to automate this process.
Please understand that Exchange Online tag is not focused on scripts at the moment, in order to better solve your problem, I will add PowerShell tag for you.
Based on my personal experience, the following script is for reference.
# Define the start and end date for the query
$startDate = (Get-Date).AddDays(-1).ToString("yyyy-MM-ddTHH:mm:ssZ")
$endDate = (Get-Date).ToString("yyyy-MM-ddTHH:mm:ssZ")
# Define the interval in hours
$intervalHours = 1
# Loop through the intervals and retrieve the message trace logs
for ($i = 0; $i -lt 24; $i += $intervalHours) {
$intervalStart = (Get-Date).AddHours(-$i - $intervalHours).ToString("yyyy-MM-ddTHH:mm:ssZ")
$intervalEnd = (Get-Date).AddHours(-$i).ToString("yyyy-MM-ddTHH:mm:ssZ")
# Retrieve the message trace logs for the interval
$messageTrace = Get-MessageTrace -StartDate $intervalStart -EndDate $intervalEnd -PageSize 100000
# Save the logs to a file
$fileName = "MessageTrace_$($intervalStart)_to_$($intervalEnd).csv"
$messageTrace | Export-Csv -Path $fileName -NoTypeInformation
}
# Combine all the CSV files into a single file
$combinedFileName = "Combined_MessageTrace_$(Get-Date -Format 'yyyyMMdd').csv"
Get-ChildItem -Path . -Filter "MessageTrace_*.csv" | ForEach-Object {
Import-Csv -Path $_.FullName
} | Export-Csv -Path $combinedFileName -NoTypeInformation
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".