Quick answer: New-ComplianceSearch only defines a search. Start-ComplianceSearch runs it, and Get-ComplianceSearch shows the result. In Microsoft 365, connect to Security & Compliance PowerShell first, not Exchange Online.
Connect-IPPSSession -UserPrincipalName admin@contoso.onmicrosoft.com -EnableSearchOnlySession
New-ComplianceSearch -Name "Hold-Tailspin Toys" -ExchangeLocation "Research Department" -ContentMatchQuery "'Patent' AND 'Project Tailspin Toys'"
Start-ComplianceSearch -Identity "Hold-Tailspin Toys"
Get-ComplianceSearch -Identity "Hold-Tailspin Toys" | Format-List
What does New-ComplianceSearch do?
It creates a compliance search (a content search) in Exchange Server 2016 or later, or in the Microsoft Purview compliance portal. It sets the search criteria: which mailboxes or sites, and what content to match (Microsoft Learn).
Two rules:
- A search needs at least one location, such as
-ExchangeLocationfor mailboxes or-SharePointLocationfor sites. - Creating a search doesn't run it. Run it with
Start-ComplianceSearch.
How do I connect in Microsoft 365?
The cmdlet lives in Security & Compliance PowerShell, so Connect-ExchangeOnline won't load it. In the cloud, Microsoft lists two requirements:
- Exchange Online PowerShell module version 3.9.0 or later (August 2025).
- The
-EnableSearchOnlySessionswitch onConnect-IPPSSession.
Update-Module -Name ExchangeOnlineManagement
Connect-IPPSSession -UserPrincipalName admin@contoso.onmicrosoft.com -EnableSearchOnlySession
New to the module? See how to install Exchange Online PowerShell. On-premises, run the cmdlet in the Exchange Management Shell.
How do I create and run a search?
Search every mailbox in a distribution group, all items:
New-ComplianceSearch -Name "Hold Project X" -ExchangeLocation "Finance Department"
No -ContentMatchQuery, so all items in those mailboxes are searched.
Search only matching messages:
New-ComplianceSearch -Name "Hold-Tailspin Toys" -ExchangeLocation "Research Department" -ContentMatchQuery "'Patent' AND 'Project Tailspin Toys'"
Then run it:
Start-ComplianceSearch -Identity "Hold-Tailspin Toys"
-ContentMatchQuery takes plain text or Keyword Query Language (KQL). Microsoft's keyword queries and search conditions lists the properties you can search.
How do I check results?
Get-ComplianceSearch
Get-ComplianceSearch -Identity "Hold-Tailspin Toys" | Format-List
The first line lists all searches. Item counts and size (Items, Size, SuccessResults, ExchangeLocation) only appear when you name the search with -Identity (Microsoft Learn).
How do I search an inactive mailbox?
Put a period before the inactive mailbox's primary SMTP address, and skip the existence check:
New-ComplianceSearch -Name "AnnBeebe-InactiveMailbox" -ExchangeLocation .annb@contoso.onmicrosoft.com -AllowNotFoundExchangeLocationsEnabled $true
-AllowNotFoundExchangeLocationsEnabled $true is also needed for guest users, unlicensed users of Office apps, and on-premises users synced to Microsoft 365.
What are the key parameters?
| Parameter | Where | What it does |
|---|---|---|
-Name |
Both | Search name (required). No spaces if you also use -Case |
-ExchangeLocation |
Both | Mailbox or group email addresses, or All (by itself) |
-ExchangeLocationExclusion |
On-premises only | Mailboxes to skip when -ExchangeLocation is All |
-ContentMatchQuery |
Both | Text or KQL filter; omit to return everything |
-SharePointLocation |
Cloud only | Site URLs, or All |
-PublicFolderLocation |
Cloud only | All to include all public folders |
-Case |
Cloud only | eDiscovery Standard case to attach the search to |
-AllowNotFoundExchangeLocationsEnabled |
Both | $true to include inactive, guest or synced users |
-IncludeUserAppContent |
Cloud only | Search cloud storage for users without a regular account |
-Language |
Both | Culture code, for example ja-JP |
What permissions do I need?
On-premises, the cmdlet is in the Mailbox Search role, which by default is assigned only to the Discovery Management role group. In Microsoft 365, you need Microsoft Purview compliance portal permissions.
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
| "The term 'New-ComplianceSearch' is not recognized" | Connected with Connect-ExchangeOnline | Use Connect-IPPSSession |
| Search fails or errors in the cloud | Module older than 3.9.0, or no search-only session | Update the module; add -EnableSearchOnlySession |
| Search exists but shows no results | It was never started | Run Start-ComplianceSearch |
Items and Size are blank |
Ran Get-ComplianceSearch without -Identity |
Add -Identity "<name>" |
| Search fails on a mailbox | Not a regular user mailbox (inactive, guest) | Add -AllowNotFoundExchangeLocationsEnabled $true |
Mailboxes cleared after adding -Case |
-Name contains spaces |
Use a name without spaces |
| Exclusion has no effect | -ExchangeLocationExclusion works only on-premises |
Exclude by listing mailboxes instead of All |
Summary
- New-ComplianceSearch defines a search; Start-ComplianceSearch runs it.
- In Microsoft 365, use
Connect-IPPSSession -EnableSearchOnlySessionwith module 3.9.0+. - Give at least one location;
-ContentMatchQueryis optional. - Use
Get-ComplianceSearch -Identityto see item counts.
Related: Search-Mailbox, Search-MailboxAuditLog, Install Exchange Online 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 display a month.