Sunday, October 4, 2015

How to delete a user's mailbox content in Exchange Server or Exchange Online

Sometimes you have to delete user's mailbox content on Exchange Server or Exchange Online but you need to preserve mailbox object itself with its configuration like forwarding, permissions, assigned policies, etc.
Here is procedure how you can accomplish this task.

  • You have to be a member of built-in "Discovery Management" admin role in Exchange.
  • You have to be a member of custom Exchange admin role that includes roles: Mailbox Import Export, Mailbox Search

If you have "In-Place Hold" feature activated on mailbox you probably need to deactivate it prior to deletion if your target goal is really to delete content with no recovery.

Step 1.
Log on to the EMS (Exchange Management Shell) or in the case of Exchange Online log on via PowerShell
Step 2.
Run cmdlet on the mailbox you want to clear content:

Search-Mailbox -identity "<mailbox name>" -DeleteContent -force
Wait for the command complete. Depending on number of mailbox items it can take some time to complete. As an optional step you can estimate number of items prior to deletion using cmdlet:
Get-MailboxFolderStatistics <mailbox name> | Select Identity, ItemsInFolder

No comments:

Post a Comment