Others

Fix Search-Mailbox DeleteContent Parameter Not Recognized in Exchange

John WilsonJohn Wilson Nov 3, 2026 869 views

Question details

Users encounter a NamedParameterNotFound error for the -DeleteContent switch when attempting to run the Search-Mailbox cmdlet in Exchange Online PowerShell.

Fix Search-Mailbox DeleteContent Parameter Not Recognized Error
Product
Exchange Online PowerShell
Device & OS
not provided
Scenario
An administrator is attempting to search and delete specific email content across mailboxes using the Search-Mailbox cmdlet via PowerShell.
Observed behavior
The command fails with an error stating that the DeleteContent parameter is not recognized, even though other parameters like -EstimateResultOnly work successfully.
Before you start

Ensure you have global administrator or Exchange administrator credentials, as you will need to modify Role Based Access Control (RBAC) settings in the Exchange Admin Center.

Solution 1Recommended

Assign the Mailbox Import Export Role

The -DeleteContent switch requires specific elevated permissions that are not assigned to Exchange administrators by default. You must manually assign the Mailbox Import Export role.

By default, no admin accounts or role groups are granted the Mailbox Import Export role due to the sensitive nature of permanently deleting mailbox content. You must add this role to an existing role group or create a new one.

1
Open the Exchange Admin Center

Log in to the Microsoft 365 admin center and navigate to the Exchange Admin Center (EAC).

2
Navigate to Admin Roles

In the left-hand navigation pane, click on 'Roles' and then select 'Admin roles'.

3
Modify or Create a Role Group

Select an existing role group (such as Organization Management) or create a new one. Click on the 'Permissions' tab and add the 'Mailbox Import Export' role.

4
Add Members and Wait for Replication

Ensure your admin account is a member of this role group. Save the changes and wait 15 to 60 minutes for the permissions to replicate across Microsoft's servers before retrying your PowerShell command.

Assign the Mailbox Import Export Role
Role Assignment: Once the role is active, the -DeleteContent parameter will be recognized by the Search-Mailbox cmdlet without throwing the NamedParameterNotFound error.
Free Microsoft Office alternative

Looking for a Lightweight, Everyday Office Suite?

While resolving Exchange server and PowerShell issues requires administrative expertise, managing your daily documents shouldn't be complicated. WPS Office is a free, lightweight, and highly compatible alternative to Microsoft Office for your word processing, spreadsheet, and presentation needs.

  1. 1. Download the Installer: Visit the official WPS Office website and click the Free Download button to get the setup file.
  2. 2. Install WPS Office: Run the downloaded installer and follow the simple on-screen instructions to complete the setup.
  3. 3. Start Creating: Open WPS Office and instantly start working on your documents, spreadsheets, or presentations with full Microsoft format compatibility.
Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx).Lightweight installation with blazing fast startup speeds compared to traditional heavy office suites.Familiar ribbon interface ensuring zero learning curve for seamless user migration.Free access to essential office productivity tools, robust PDF editing, and built-in cloud collaboration.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Search-Mailbox work with -EstimateResultOnly but fails with -DeleteContent?

The -EstimateResultOnly parameter only requires basic mailbox search permissions, which are standard for many admin roles. However, the -DeleteContent parameter requires the specialized 'Mailbox Import Export' role, which Microsoft does not grant by default for security reasons.

How long does it take for the Mailbox Import Export role to take effect?

After assigning the role in the Exchange Admin Center, it typically takes anywhere from 15 to 60 minutes for the permissions to fully replicate and become active in your Exchange Online PowerShell session. You may need to disconnect and reconnect your PowerShell session.

Is the Search-Mailbox cmdlet still supported by Microsoft?

No, Microsoft has officially retired the Search-Mailbox cmdlet. While it may still work for some tenants, it prompts a retirement warning and restricts results to a maximum of 10,000 items. Microsoft strongly recommends using Microsoft Purview eDiscovery for future content search and deletion.

Can I use Search-Mailbox to delete content only from the Deleted Items folder?

Yes. If you have the correct permissions, you can narrow down your target by using the -SearchQuery parameter. For example, using -SearchQuery 'folder:"Deleted Items"' along with your delete switch will restrict the deletion to just that folder.