EASYENTRA Blog

News & Updates

How to Search the Microsoft 365 Unified Audit Log  

How to Search the Microsoft 365 Unified Audit Log

When something goes wrong in Microsoft 365, IT admins need answers fast. They need to know who accessed a mailbox, who deleted a file from SharePoint, or who changed admin rights. The primary source for this data is the Microsoft 365 Unified Audit Log. It captures activity across Exchange Online, SharePoint, OneDrive, Teams, Entra ID, and other Microsoft 365 services. Understanding how to search and analyse audit logs is an essential skill for troubleshooting, security investigations, compliance audits, and incident response.

Enable Audit Logging in Microsoft 365

Before searching for audit events, verify that audit logging is enabled in your tenant.

Important Note: Audit events are only collected after audit logging has been enabled. Events that occurred before audit logging was enabled cannot be recovered later.

To verify whether Unified Audit Logging is enabled, connect to Exchange Online PowerShell and run.

Get-AdminAuditLogConfig | Select-Object UnifiedAuditLogIngestionEnabled 

If status is False, enable the Microsoft 365 audit logging by running the following command.

Set-AdminAuditLogConfig -UnifiedAuditLogIngestionEnabled $true 

After enabling auditing, Microsoft may require some time before events begin appearing in search results.

How Long Microsoft Audit Data is Retained

Before beginning an investigation, it is important to understand how long audit data is retained.

License TypeDefault Retention
Microsoft 365 Business90 days
Microsoft 365 E390 days
Microsoft 365 E51 year
Microsoft Purview Audit Premium1 year or longer
Custom Retention PoliciesUp to 10 years

If an event falls outside the retention window, it may no longer be available for investigation.

How to Search the Unified Audit Log in Microsoft Purview

Microsoft provides a graphical interface for searching audit records through the Purview portal. This approach is useful for occasional investigations and administrators who prefer a web-based interface. To search the unified audit log using Microsoft Purview portal, follow the below mentioned steps.

  1. Sign in to the Microsoft Purview portal.
  2. Expand Solutions in the left navigation pane.
  3. Select Audit.
  4. Open the Search tab.
  5. Specify a Start date and End date.
  6. Select one or more Activities if you want to filter for specific events.
  7. Optionally specify Users, Workloads, Files, Sites, or other available filters.
  8. Click Search. Review the returned audit records.

If you need to perform additional analysis, you can export the results for offline review.

Why the Microsoft Purview Portal Falls Short for Audit Logging

Microsoft provides audit search capabilities through the Purview compliance portal, and for occasional searches it works reasonably well. However, administrators often run into limitations when dealing with larger environments.

For example, searches must be performed manually, filtering options are limited, and exporting large datasets can become cumbersome. Integrating audit data into automation workflows, SIEM platforms, or scheduled reporting is also difficult through the web interface.

PowerShell provides far greater flexibility, making it the preferred option for many security and Microsoft 365 administrators.

How to Search the Microsoft 365 Unified Audit Log with PowerShell

PowerShell provides significantly more flexibility than the Purview portal and is often the preferred approach for security teams and Microsoft 365 administrators. Before running audit searches:

  • Install the Exchange Online Management module.
  • Connect to Exchange Online.
  • Ensure the account has either the Audit Logs or View-Only Audit Logs role assigned.

Basic Cmdlets for Microsoft 365 Auditing

The primary cmdlet used for audit searches is Search-UnifiedAuditLog. Several parameters determine what data is returned.

ParameterPurposeExample
-StartDateBeginning of search window(Get-Date).AddDays(-7)
-EndDateEnd of search window(Get-Date)
-OperationsSpecific activity types‘MailItemsAccessed’
-RecordTypeWorkload categoryAzureActiveDirectory
-UserIdsFilter by user(s)‘user@contoso.com’
-ResultSizeRecords per page (max 5,000)5000
-SessionIdUsed for pagination‘AuditSession1’
-SessionCommandPagination directionReturnNextPreviewPage

A particularly important limitation is that a single search can only return up to 5,000 records at a time. Administrators investigating larger datasets must use pagination to retrieve additional results.

Example 1: Search Mailbox Access Activity

A common security investigation involves determining whether a mailbox has been accessed. The following example searches for mailbox access events during the past seven days.

Search-UnifiedAuditLog ` 
    -StartDate (Get-Date).AddDays(-7) ` 
    -EndDate (Get-Date) ` 
    -Operations 'MailItemsAccessed' ` 
    -UserIds 'user@contoso.com' 

This can help identify access patterns during a suspected account compromise investigation.

Example 2: Search SharePoint File Deletions

If users report missing files, audit logs can reveal who deleted them and when.

Search-UnifiedAuditLog ` 
    -StartDate (Get-Date).AddDays(-7) ` 
    -EndDate (Get-Date) ` 
    -RecordType SharePoint ` 
    -Operations FileDeleted 

This approach is often much faster than manually checking site activity through the SharePoint interface.

Example 3: Investigate Administrative Changes

Administrative actions are also recorded in the Unified Audit Log.

Search-UnifiedAuditLog ` 
    -StartDate (Get-Date).AddDays(-30) ` 
    -EndDate (Get-Date) ` 
    -RecordType AzureActiveDirectory ` 
    -Operations "Add member to role" 

This can help identify when privileged roles were assigned and by whom.

Parsing AuditData: Every result contains an AuditData field that is a raw JSON string, not a native object. Always convert it with $_.AuditData | ConvertFrom-Json. To explore fields for an unknown record type, run $parsed | ConvertTo-Json -Depth 5 on a sample record first.

Whether you’re investigating a security incident, tracking administrative changes, or meeting compliance requirements, the Microsoft 365 Unified Audit Log is an essential resource. By combining the ease of the Purview portal with the power and flexibility of PowerShell, administrators can audit activity more efficiently and gain deeper insight into what’s happening across their Microsoft 365 environment.

Free 30-minute demo

try 30 days for free

GET EASYENTRA NEWS

Opt out at any time

“One of the best products I've used.”
Gary Shurland
Chief Information Officer, Mirick, United States
“This tool has been invaluable in streamlining our IT processes.”
Tyson Mckay
Chief Information Officer, Southwest Network, United States
“This product has been a miracle for our Help Desk. EasyEntra has completely transformed how we handle Microsoft 365 administration.”
Doug Sanders
Manager of Technical Customer Support, Junior Achievement USA, United States
“Your product is such a time saver. I love it!”
Scott Fehr
IT Infrastructure, MEC Aerial Work Platforms, United States
“It's a good product and saves us lots of time for these ongoing quick admin tasks.” 
Chris McFerran
Managing Director, CTech IT Solutions Ltd, United Kingdom
“EasyEntra has significantly streamlined our workflow, simplifying everything. It feels almost like a revolution.”
Johan Sadelius
IT-chef, Arjeplog Kommun, Sweden
I greatly appreciate your assistance and willingness to enhance the already outstanding product.”
Michael I. Wilson
Executive Director of Information Technology, Archdiocese Of Washington, United States
“It's great not having to switch back and forth between the O365 admin center and the Teams admin center to assign groups. I am sold!”
Thomas Madden
Director Information Technology, AutoPayPlus, United States
“I would highly recommend organizations use the solution as it greatly simplifies various tasks.”
S. Roger Singh
Chief Technology Officer, Prasad & Company LLP, Canada
“EasyEntra is time-saving. Love the copy/paste for user/computer groups and the copy to new user.”
Damian Nita
Associate Network Administrator, Shenandoah Valley Westminster-Canterbury, United States
“EasyEntra has transformed our daily IT operations by simplifying user management, reducing errors, and enhancing overall efficiency.”
Henrik Nefling
IT- and Digitalization Manager, Animal Protection Denmark, Denmark