Skip to content
iBlockSpam
Running email day to day

How do you use the Microsoft 365 audit log to investigate an email incident?

By iBlockSpam Team How we check our guides Updated 12 min read 8 sources
Short answer

Search Microsoft Purview Audit for the compromised user over the attack window. Look for New-InboxRule, Set-InboxRule and UpdateInboxRules (rules), Set-Mailbox with ForwardingSmtpAddress (forwarding), Send (mail the attacker sent) and MailItemsAccessed (what they read). Audit (Standard) keeps records for 180 days; Audit (Premium) keeps Exchange records for one year by default.

When a mailbox is compromised, message trace tells you what mail flowed. The audit log tells you what the attacker did: which rules they created, where they forwarded mail, what they sent and what they read. This guide covers where to search, which events matter, how long records last, the PowerShell limits, and a step-by-step investigation. Portal paths and limits are as Microsoft documents them at the time of writing (November 2026).

If the account is still compromised right now, contain it first with our Microsoft 365 compromised account remediation steps, then come back here.

What is the Microsoft 365 audit log?

The Microsoft 365 audit log is Microsoft Purview Audit's unified record of user and admin activity across Microsoft 365. Microsoft says it "captures, records, and retains thousands of user and admin operations performed in dozens of Microsoft services and solutions" (Microsoft Learn). For email, two kinds of record matter:

  • Mailbox audit records: actions inside a mailbox, such as sending, deleting, accessing mail and changing inbox rules.
  • Exchange admin records: cmdlets that change configuration, such as Set-Mailbox. Microsoft says the audit log "doesn't record cmdlets that begin with the verbs Get-, Search-, or Test-" (audit log activities).

Entra ID sign-ins appear as UserLoggedIn records in the same log, which helps you tie mailbox activity to a sign-in.

Is auditing turned on in my tenant?

Auditing is on by default, but check both layers rather than assume.

Unified audit log search is on by default for Microsoft 365 and Office 365 enterprise organizations. In Exchange Online PowerShell, run:

Get-AdminAuditLogConfig | Format-List UnifiedAuditLogIngestionEnabled

True means it's on. Microsoft warns that in Security & Compliance PowerShell this property "is always False," so use Exchange Online PowerShell (Microsoft Learn). If it's off, turn it on with Set-AdminAuditLogConfig -UnifiedAuditLogIngestionEnabled $true. Nothing is recorded for the period it was off.

Mailbox audit logging "is turned on by default in all organizations" (Manage mailbox auditing), and Microsoft says that started in January 2019 (Microsoft Learn). Check it with:

Get-OrganizationConfig | Format-List AuditDisabled

False means mailbox auditing is on. It covers user, shared and Microsoft 365 Group mailboxes, but not resource or public folder mailboxes.

Two catches:

  1. Non-E5 users. Microsoft says mailbox audit events "return only for users with E5 licenses" in some searches. Its workaround is Set-Mailbox -Identity <mailbox> -AuditEnabled $true, and if searches still return nothing, setting it to $false and back to $true. Do this now for key mailboxes, not during an incident.
  2. Audit bypass. An account with an audit bypass association isn't logged anywhere it acts. Check for unexpected entries with Get-MailboxAuditBypassAssociation -ResultSize Unlimited | Where-Object {$_.AuditBypassEnabled}.

Audit (Standard) vs Audit (Premium): how long are records kept?

Audit (Standard) keeps records for 180 days; Audit (Premium) keeps Exchange, SharePoint, OneDrive and Entra ID records for one year by default and can keep them up to 10 years with an add-on.

Capability Audit (Standard) Audit (Premium)
Enabled by default Yes Yes
Audit search, Search-UnifiedAuditLog, Audit Search Graph API, CSV export Yes Yes
Default retention 180 days 1 year for Exchange, SharePoint, OneDrive and Entra ID; 180 days for others
Custom audit log retention policies No Yes, up to 1 year (10 years with add-on)
Export limit from the search UI 50,000 rows 1,000,000 rows
Intelligent insights (such as the sensitivity label of accessed mail) No Yes
Management Activity API bandwidth Baseline About twice the Standard bandwidth

Sources: Microsoft Learn: auditing solutions and Microsoft Learn: search the audit log.

The 180-day Standard retention dates from 2023. Records created before October 17, 2023 were kept for 90 days. In the same change, Microsoft said Audit (Standard) customers would get "detailed logs of email access and more than 30 other types of log data" that had been Premium-only, starting in September 2023 (Microsoft Security Blog). That's why MailItemsAccessed is now part of Audit (Standard).

Premium's one-year retention applies to users with Office 365 E5, Microsoft 365 E5, Microsoft Purview Suite (formerly Microsoft 365 E5 Compliance) or the E5 eDiscovery and Audit add-on. Everyone else gets 180 days. Business email compromise is often discovered months later, when a supplier chases an unpaid invoice, so 180 days can be tight. If you might need longer, export records to your own storage or a SIEM through the Office 365 Management Activity API. Our comparisons of Microsoft 365 E3 vs E5 email security and Microsoft 365 business plans show which plans include what.

Which audit events matter for email incidents?

The events that matter most are inbox rule changes, forwarding changes, mailbox permission changes, sent mail and mail access.

Activity (friendly name) Operation Logged by default? What it tells you
Created new inbox rule in Outlook web app New-InboxRule Yes (admin cmdlet record) A rule was created in Outlook on the web or PowerShell
Modified inbox rule from Outlook web app Set-InboxRule Yes An existing rule was changed
(Exchange cmdlet) Remove-InboxRule Yes A rule was deleted, often to cover tracks
Updated inbox rules from Outlook client UpdateInboxRules Yes A rule was created, changed or removed from desktop Outlook
(Exchange admin cmdlet) Set-Mailbox Yes Mailbox settings changed, including forwarding
Added delegate mailbox permissions Add-MailboxPermission Yes Someone was given FullAccess to a mailbox
Sent message Send Yes (owner and admin) A message was sent, replied to or forwarded
Sent message using Send As permissions SendAs Yes (delegate and admin) Another user sent as the mailbox owner
Accessed mailbox items MailItemsAccessed Yes Mail was read or synced by a client or protocol
Deleted messages from Deleted Items folder SoftDelete Yes Mail was deleted, for example the attacker's sent items
User signed in to mailbox MailboxLogin No A sign-in to the mailbox
Search items in a mailbox SearchQueryInitiated No What someone searched for in the mailbox

Names come from Microsoft's audit activities list, mailbox auditing page and mailbox rules page. Add the two off-by-default actions before you need them:

Set-Mailbox -Identity cfo@example.com `
  -AuditOwner @{Add="MailboxLogin","SearchQueryInitiated"}

Microsoft says SearchQueryInitiated "must be enabled explicitly" for Exchange Online (Get started with auditing). Be aware that customizing a sign-in type's actions stops Microsoft from adding new default actions to it; Set-Mailbox -DefaultAuditSet Owner restores the managed defaults.

Inbox rules and forwarding

Rules and forwarding are how attackers hide replies and keep copying mail after a password reset. Our guide to malicious inbox rules and auto-forwarding shows how to find the rules that exist now with Get-InboxRule. The audit log adds when they were made and from where.

In a New-InboxRule record, Microsoft says the ObjectId field shows the full rule name, Parameters shows its conditions and actions (such as From and MoveToFolder), and UserId shows who created it (Microsoft Learn).

Forwarding set on the mailbox itself shows up as Set-Mailbox. In Parameters, ForwardingSmtpAddress is the destination. If DeliverToMailboxAndForward is True, a copy stays in the mailbox; if False, mail only goes to the forwarding address. Microsoft notes that a restricted admin scoped by administrative units can't see Set-Mailbox records, so run this search with an unrestricted admin account.

MailItemsAccessed: what did the attacker read?

MailItemsAccessed covers "all mail protocols: POP, IMAP, MAPI, EWS, Exchange ActiveSync, and REST" (Microsoft Learn). Microsoft describes it as part of Audit (Standard) and "enabled by default for users that are assigned an Office 365 E3/E5 or Microsoft 365 E3/E5 license." If your users have Business Basic, Standard or Premium, confirm it's in their audited actions with Get-Mailbox <user> | Select-Object -ExpandProperty AuditOwner.

It records two kinds of access:

  • Bind: one message opened. Records list each message's InternetMessageId, with binds in a 2-minute interval grouped into one record.
  • Sync: desktop Outlook for Windows or Mac downloading a folder. Microsoft says "all mail items in the synced folder are assumed to be compromised."

To separate the attacker from the real user, compare ClientIPAddress, ClientInfoString and SessionId with the attacker's sign-in. If a sync came from the attacker's context, Microsoft's advice is to assume they "synced all mail items to their client, which means the entire mailbox is compromised." That matters if the mailbox held personal, health or financial data you may have to report.

How do you search the audit log in the Microsoft Purview portal?

Search the audit log in the Microsoft Purview portal at purview.microsoft.com under the Audit solution. You need the Audit Logs or View-Only Audit Logs role; by default the Audit Reader and Audit Manager role groups have them. The older Classic Search retired on November 30, 2023, so every search now runs as a background job (Microsoft Learn).

  1. Sign in to the Microsoft Purview portal and select the Audit solution card. If it isn't shown, select View all solutions, then Audit under Core.
  2. Set the Date and time range (UTC). The default is the last seven days, and the maximum range is 180 days.
  3. Enter operation names in Activities - operations names, for example New-InboxRule,Set-InboxRule,Remove-InboxRule,UpdateInboxRules,Send. Microsoft says names must be exact or "no results are returned."
  4. Add the compromised account under Users.
  5. Name the search and select Search. Jobs keep running after you close the browser, completed jobs are kept for 30 days, and each admin can run up to 10 jobs at once (only one of them unfiltered). Microsoft says broad searches in large tenants can take up to 48 hours.
  6. Open a result for its details flyout, or select Export to download a CSV.

For forwarding changes, leave activities blank, then filter the results to Set-Mailbox.

How do you search the audit log with PowerShell?

Use Search-UnifiedAuditLog in Exchange Online PowerShell. Its paging rules decide how much you get back (Microsoft Learn):

Option Records returned Sorted?
No -SessionCommand 100 by default, up to 5,000 with -ResultSize Yes
-SessionCommand ReturnNextPreviewPage Up to 5,000 in total Yes, by date
-SessionCommand ReturnLargeSet Up to 50,000 across pages No
Switching commands within one SessionId Capped at 10,000 Mixed
Search-UnifiedAuditLog -StartDate "2026-10-01" -EndDate "2026-11-03" `
  -UserIds user@example.com `
  -Operations New-InboxRule,Set-InboxRule,Remove-InboxRule,UpdateInboxRules,Set-Mailbox,Send,MailItemsAccessed `
  -SessionId "incident-001" -SessionCommand ReturnLargeSet -ResultSize 5000 |
  Export-Csv incident-001.csv -NoTypeInformation -Append

Run the same command with the same SessionId until it returns nothing. Dates without a time zone are treated as UTC, and the details sit in the AuditData column as JSON; add -Formatted to make it easier to read. A -HighCompleteness switch, in preview at the time of writing and not in every tenant, trades speed for more complete results. For ongoing exports, Microsoft recommends the Office 365 Management Activity API rather than scripts.

Searching by user won't show what a delegate did in that mailbox, or activity in a shared mailbox. For that, Microsoft suggests searching by the mailbox's GUID: -FreeText (Get-Mailbox <mailbox>).ExchangeGuid.

How do you investigate a compromised mailbox step by step?

Investigate in a fixed order: set the window, find the attacker's footprint, then scope what they changed, sent and read. Contain the account first, using Microsoft 365 compromised account remediation and the warning signs in signs your email account is compromised. Then:

  1. Set the window. Start a few days before the first suspicious sign-in or phishing click, and end now.
  2. Find the attacker's IP addresses. Search the user's activity, including UserLoggedIn, and note IP addresses and clients that don't match the user's normal pattern.
  3. Search rule and forwarding changes (New-InboxRule, Set-InboxRule, Remove-InboxRule, UpdateInboxRules, Set-Mailbox, Add-MailboxPermission). Record each rule's name and actions, and each forwarding address.
  4. Search Send and SoftDelete records from the attacker's IPs and sessions to list what they sent, to whom, and what they deleted afterwards. Cross-check with message trace.
  5. Search MailItemsAccessed for the same context to scope what they read or synced.
  6. Search across the tenant for the attacker's IP addresses (-IPAddresses) and rule names, because attackers often reuse them on other mailboxes.
  7. Clean up the phish that started it. Use remove a phishing email from all mailboxes for the original message and any the attacker sent internally.
  8. Export everything to CSV and keep it with your incident notes, especially if retention is 180 days.

Audit records are typically available 60 to 90 minutes after an event, and Microsoft doesn't guarantee a time (Microsoft Learn). Re-run searches later before concluding that nothing happened. If the attacker asked a customer or supplier to pay a new bank account, follow business email compromise wire transfer recovery at the same time.

If you have Defender for Office 365 Plan 2, automated investigation and response also flags forwarding and delegation it finds, and Threat Explorer shows who else received the same phish.

Next steps

  1. Today, confirm UnifiedAuditLogIngestionEnabled is True and AuditDisabled is False, and check for unexpected audit bypass associations.
  2. Add MailboxLogin and SearchQueryInitiated to AuditOwner for finance, payroll and executive mailboxes, and set AuditEnabled on non-E5 mailboxes.
  3. Give one or two named people the Audit Reader role group before an incident.
  4. Decide whether 180 days is enough, or export audit data somewhere you control.
  5. Reduce how often you need this guide. Most mailbox compromises start with a phishing email; iBlockSpam filters phishing and spoofing at the MX before mail reaches Microsoft 365. See how it works, or paste a suspicious message into our free Email Header Analyzer.

Browse our other email operations guides.

Frequently asked questions

How long does Microsoft 365 keep audit log records?

With Audit (Standard), 180 days for records created on or after October 17, 2023; older Standard records were kept for 90 days. With Audit (Premium), for example Microsoft 365 E5, Exchange, SharePoint, OneDrive and Entra ID records are kept for one year by default, and retention policies can extend that. Ten-year retention needs an extra add-on license.

Is mailbox auditing turned on by default in Exchange Online?

Yes. Microsoft says mailbox audit logging is on by default in all organizations, and it has been since January 2019. Check it with Get-OrganizationConfig and the AuditDisabled property; False means auditing is on. Some mailbox events for users without E5 licenses may not show in searches until you set AuditEnabled on those mailboxes.

What does MailItemsAccessed show in an investigation?

It records mail access by any protocol or client. Bind records list individual messages by Internet Message ID, aggregated over two-minute intervals. Sync records cover whole folders downloaded by desktop Outlook, and Microsoft says to assume every item in a synced folder is compromised. Compare IP address, client and session ID with the attacker's activity.

How soon do events appear in the Microsoft 365 audit log?

Microsoft doesn't guarantee a time. For core services such as Exchange, SharePoint, OneDrive and Teams, records are typically available 60 to 90 minutes after the event, and other services can take longer. Don't conclude that nothing happened from a search run minutes after an incident.

How do I find who set up forwarding on a mailbox in the audit log?

Search the audit log over the relevant dates without selecting an activity, then filter results to Set-Mailbox. Open each record and look at the Parameters field. ForwardingSmtpAddress shows the destination, DeliverToMailboxAndForward shows whether a copy stayed in the mailbox, and UserId shows who made the change.

Can the audit log show what an attacker searched for in a mailbox?

Only if you turned it on beforehand. The SearchQueryInitiated mailbox action isn't logged by default for Exchange Online; Microsoft says you enable it per user with Set-Mailbox and AuditOwner add SearchQueryInitiated. Searches made before you enable it aren't recorded, so add it now for finance, payroll and executive mailboxes.

Sources

  1. Microsoft Learn: Learn about auditing solutions in Microsoft Purview
  2. Microsoft Learn: Search the audit log
  3. Microsoft Learn: Manage mailbox auditing
  4. Microsoft Learn: Use MailItemsAccessed to investigate compromised accounts
  5. Microsoft Learn: Search the audit log to investigate common support issues
  6. Microsoft Learn: Identify who modified mailbox rules
  7. Microsoft Learn: Search-UnifiedAuditLog
  8. Microsoft Security Blog: Expanding cloud logging to give customers deeper security visibility (July 2023)

See how your domain measures up

Run a free Email Health Check: MX, SPF, DKIM, DMARC and transport security in one scan, with the raw records shown. No sign-up.

Keep reading