Quick answer: Search-MailboxAuditLog searches one mailbox's audit log and returns the results in your PowerShell session. Microsoft says the cmdlet will be deprecated in Exchange Online, so for cloud mailboxes use Search-UnifiedAuditLog instead. It still works in on-premises Exchange.
Search-MailboxAuditLog -Identity kwok -LogonTypes Admin,Delegate -StartDate 1/1/2018 -EndDate 12/31/2018 -ResultSize 2000
Source: Search-MailboxAuditLog on Microsoft Learn.
Is Search-MailboxAuditLog deprecated?
In Exchange Online, yes. Microsoft's cmdlet reference says it will be deprecated in the cloud-based service and points to Search-UnifiedAuditLog for audit log data. See the announcement.
| Where | Use |
|---|---|
| Exchange Server (2010 to Subscription Edition) | Search-MailboxAuditLog |
| Exchange Online, new scripts | Search-UnifiedAuditLog |
| Exchange Online, old scripts | Still runs for now. Plan the move. |
Do I need to turn on mailbox auditing first?
Not in Exchange Online. Mailbox audit logging is on by default for user, shared and Microsoft 365 Group mailboxes. Check it for the whole organization:
Get-OrganizationConfig | Format-List AuditDisabled
False means auditing is on. While it's on, setting AuditEnabled on a single mailbox is ignored. To see which actions a mailbox logs:
Get-Mailbox -Identity laura@contoso.onmicrosoft.com | Format-List DefaultAuditSet
Get-Mailbox -Identity laura@contoso.onmicrosoft.com | Select-Object -ExpandProperty AuditOwner
Resource and public folder mailboxes don't support mailbox auditing. Source: Manage mailbox auditing.
How do I search one mailbox?
Connect to Exchange Online PowerShell (or the Exchange Management Shell on-premises), then run:
Search-MailboxAuditLog -Identity kwok -LogonTypes Admin,Delegate -StartDate 1/1/2018 -EndDate 12/31/2018 -ResultSize 2000
This returns up to 2,000 entries for admin and delegate access to Kwok's mailbox in 2018.
The search is synchronous: results come back in the session. To search many mailboxes and get the results by email, Microsoft points to New-MailboxAuditLogSearch.
Which logon types can I filter on?
| LogonTypes value | Who it covers |
|---|---|
Admin |
Admin access, such as eDiscovery searches or impersonation |
Delegate |
Users with SendAs, SendOnBehalf or Full Access permission |
Owner |
The mailbox owner. Needs -ShowDetails. |
How do I find who deleted an email?
Search the owner's actions with -ShowDetails, then filter for HardDelete:
Search-MailboxAuditLog -Identity kwok -LogonTypes Owner -ShowDetails -StartDate 1/1/2017 -EndDate 3/1/2017 | Where-Object {$_.Operation -eq "HardDelete"}
You can also filter with -Operations instead of Where-Object. Common values:
| Operation | What it records |
|---|---|
HardDelete |
Item purged from Recoverable Items |
SoftDelete |
Item deleted from Deleted Items |
MoveToDeletedItems |
Item moved to Deleted Items |
SendAs / SendOnBehalf |
Mail sent with delegate permission |
UpdateInboxRules |
Inbox rule added, changed or removed |
UpdateFolderPermissions |
Folder permission changed |
MailboxLogin |
Owner signed in to the mailbox |
How do I search several mailboxes at once?
Use -Mailboxes instead of -Identity:
Search-MailboxAuditLog -Mailboxes kwok,bsmith -LogonTypes Admin,Delegate -StartDate 1/1/2018 -EndDate 12/31/2018 -ResultSize 2000
You can't use -ShowDetails with -Mailboxes, so owner actions need one search per mailbox.
How do I export the results to CSV?
Pipe the output to Export-Csv:
Search-MailboxAuditLog -Identity kwok -LogonTypes Owner -ShowDetails -StartDate 1/1/2017 -EndDate 3/1/2017 | Export-Csv -Path C:\Temp\kwok-audit.csv -NoTypeInformation
What's the Search-UnifiedAuditLog equivalent?
In Exchange Online, search the unified audit log by the user who acted and the operation:
Search-UnifiedAuditLog -StartDate 11/1/2026 -EndDate 11/8/2026 -UserIds laura@contoso.onmicrosoft.com -Operations HardDelete -SessionCommand ReturnLargeSet
It returns 100 records by default. -SessionCommand ReturnLargeSet pages through up to 50,000. Dates are in UTC. Source: Search-UnifiedAuditLog on Microsoft Learn. Our Search-UnifiedAuditLog guide covers it in depth.
Troubleshooting
| Problem | Fix |
|---|---|
| "An error occurred while trying to access the audit log." | Multi-geo: the mailbox is in another region. Anchor the session to a user in that region. |
| No owner entries | Add -ShowDetails. Owner results need it. |
-ShowDetails fails with -Mailboxes |
They can't be combined. Search each mailbox with -Identity. |
| Only 1,000 results | That's the default. Set -ResultSize up to 250000. |
| Wrong date range | Dates use your computer's short date format. Quote values that include a time. |
| Cmdlet not found | Your account lacks the role. See find the permissions for a cmdlet. |
Summary
Search-MailboxAuditLogsearches one mailbox's audit log, or several with-Mailboxes.- In Exchange Online it's being deprecated. Use
Search-UnifiedAuditLog. - Mailbox auditing is on by default in Exchange Online. No
Set-Mailboxstep is needed. - Owner actions need
-ShowDetails, which doesn't work with-Mailboxes. - Default
-ResultSizeis 1,000; the maximum is 250,000.
Related: Search-UnifiedAuditLog in PowerShell · Get-MgAuditLogSignIn in PowerShell
Meeting Room 365 turns any iPad or Android tablet into a room display for Exchange and Microsoft 365 calendars. See the features or pricing: $9 a room a month.