How to delete a mailbox content in Office 365 or Exchange?

During your testing, it might be useful to be able to empty a mailbox to perform several tests.
This article explains how to empty a mailbox in Office365 or Exchange using PowerShell.

How to delete mailbox content in Office 365 or Exchange

There is a useful command in PowerShell (search-Mailbox -DeleteContent)
This cmdLet is available by default in Exchange OnPremises.
However, an additional step is necessary in Office365 to enable this cmdLet: By default, it’s not exposed because the “Mailbox Import Export” role is not set.

1. Enable “Mailbox Import Export” role

Connect to Office365 Portal.

Select Admin -> Exchange.

Click on Permissions.

Double-click on Organization Management.

Under Roles, click on the plus sign (+).

Add the Mailbox Import/Export role.

Then ensure that your account is a member of the Organization Management.

1.2 Add permissions with Powershell

you can also use the following cmdlet to add the described above permissions:

Filter by topic

Talk with Cloudiway

Behind Cloudiway is a team of experts, available to help with technical questions and useful tips to make the most out of the platform. Explain, plan and prepare your migration and/or coexistence project with us is pretty easy and cost-efficient.