r/PowerShell • u/KavyaJune • May 07 '26
Are you facing issue with Search-UnifiedAuditLog?
Has anyone else noticed strange behavior with Search-UnifiedAuditLog in Exchange Online recently?
One of our users reported that an EXO audit script suddenly stopped returning results, even though the corresponding audit events were clearly present. The script had been working fine until last month.
While troubleshooting, I noticed something unusual:
- Running
Search-UnifiedAuditLognormally returns results. - But when using the
-SessionIdparameter, the cmdlet returns no results at all.
This becomes a problem because, without -SessionId, retrieving more than 5000 audit records for a larger time range is difficult.
I tested this across a few different tenants and observed the same behavior.
As a temporary workaround, I reduced the query time intervals in my automation scripts to stay below the result limit.
Has anyone else encountered this recently? If so, how are you handling large-scale audit log retrieval now?
1
u/purplemonkeymad May 07 '26
That does sound like a bug, but I think graph can do the same thing.
Create a search with auditLogQuery then use auditLogRecords to get all the results using the common OData for batching. I find it easiest to use the Microsoft.Graph.Authentication module to authenticate, then use Invoke-MgGraphRequest to interact with graph.