Email Search Issues

How to Use the AND Operator in Exchange Search-Mailbox

Kushani NimanthikaKushani Nimanthika Oct 29, 2026 869 views

Question details

The user needs to construct a valid search query using the AND operator in Exchange 2013 Search-Mailbox to filter emails by both subject and sent date.

How to Use the AND Operator in Exchange Search-Mailbox
Product
Microsoft Exchange Server 2013
Device & OS
not provided
Scenario
Filtering messages within an on-premises Exchange 2013 environment based on multiple criteria (subject and sent date).
Observed behavior
Exchange 2013 Search-Mailbox queries fail or return inaccurate results when attempting to combine subject and sent date filters using the AND operator.
Before you start

Ensure you have the 'Mailbox Import Export' management role assigned to your administrator account, as this is required to run the Search-Mailbox cmdlet.

Solution 1Recommended

Use Correct KQL Syntax for the SearchQuery Parameter

The -SearchQuery parameter relies on Keyword Query Language (KQL), not standard PowerShell operators. The AND operator must be capitalized and properly formatted.

A common mistake when using Search-Mailbox is attempting to use the PowerShell '-and' operator inside the query string. KQL requires operators like AND, OR, and NOT to be strictly uppercase.

Additionally, ensure that dates are formatted correctly according to your server's regional settings, or use standard formatting like MM/DD/YYYY.

1
Open Exchange Management Shell

Launch the Exchange Management Shell (EMS) on your Exchange 2013 server as an administrator.

2
Format the SearchQuery string

Construct your query using uppercase AND. For example, to search for a subject and a date range: 'Subject:"Project Update" AND Sent:"01/01/2013..12/31/2013"'

3
Execute the Search-Mailbox cmdlet

Run the complete command. Example: Search-Mailbox -Identity "UserAlias" -SearchQuery 'Subject:"Project Update" AND Sent:"01/01/2013..12/31/2013"' -TargetMailbox "DiscoveryMailbox" -TargetFolder "SearchFolder"

Use Correct KQL Syntax for the SearchQuery Parameter
Syntax check: If you receive a parsing error, verify that you are using single quotes around the entire SearchQuery string and double quotes around the specific values inside it.
Free Microsoft Office alternative

Enhance Your Productivity with WPS Office

While resolving on-premises Microsoft Exchange server queries requires specialized tools like the Exchange Management Shell, handling the resulting reports, exported data, and daily communications is easier with WPS Office. WPS Office is a powerful, lightweight suite that serves as an excellent alternative to Microsoft Office.

  1. 1. Download the Installer: Visit the official WPS Office website and click the free download button.
  2. 2. Install WPS Office: Run the downloaded installer and follow the quick on-screen instructions.
  3. 3. Open Your Files: Launch WPS Office to easily open your existing Microsoft Word, Excel, or PowerPoint files without formatting loss.
Completely free and lightweight office suiteHighly compatible with Microsoft Excel (.xlsx) for managing exported mailbox dataFamiliar user interface for a seamless transition from Microsoft OfficeBuilt-in PDF editing and document conversion tools
QA img-9

Frequently Asked Questions

Why does my Search-Mailbox query return an invalid syntax error?

This usually occurs if you use standard PowerShell operators (like -and) instead of Keyword Query Language (KQL) operators. Always use a capitalized 'AND' inside the SearchQuery string.

Do I need special permissions to run the Search-Mailbox cmdlet?

Yes, you must be assigned the 'Mailbox Import Export' management role. By default, this role is not assigned to any administrator group in Exchange 2013 and must be added manually.

Can I use multiple AND operators in a single Exchange search query?

Yes, you can chain multiple conditions using AND, OR, and NOT operators in KQL, provided you format them in uppercase and use proper quotation marks for phrases.

How do I format the date for the Sent parameter in a KQL query?

Date formats generally depend on the regional settings of the Exchange server, but using the format 'MM/DD/YYYY' or 'YYYY-MM-DD' is recommended. You can specify a date range using two dots, for example: '01/01/2013..12/31/2013'.