Delete Email from Mailbox Using Powershell command

Hello, Today’s world we are getting lots of spam email to our mailbox and There are people who send the wrong email to the wrong person, we want to delete those email from our user’s mailbox. Being Exchange administrators we are sometimes tasked with performing ninja operations such as a behind-the-scenes cleanup in user mailboxes,

Administrators can use the Search-Mailbox cmdlet to search user mailboxes and then delete messages from a mailbox.

In this airtical i am going to show how we use Search-Mailbox PowerShell command to delete email from user’s Mailbox,


Search-Mailbox -Identity Abhijeet -SearchQuery ‘ AND Subject:”What’s up” ‘ -SearchDumpster:$true -TargetMailbox “Discovery mailbox” -TargetFolder “Deleted” -DeleteContent


 Permissions Required to perform Search-Mailbox Task:

Microsoft has added special Role-Based Access Controls (RBAC) to management capabilities within Exchange.

  1. Mailbox Search: The “Search-Mailbox” cmdlet is only available to users with the Exchange role “Mailbox Search”. By default this role is granted to all users of the  “Discovery Management”
  2. Mailbox Import Export: The “-DeleteContent” for Search-Mailbox is only available to users with the Exchange role “Mailbox Import Export”.

Below is the command from that we can assign above two role into it,

  1. New-ManagementRoleAssignment -Role “Mailbox Import Export” -User “Admin” 
  2. New-ManagementRoleAssignment -Role “Mailbox Search” -User “Admin”

Or  New-ManagementRoleAssignment -Role “Mailbox Search” -User “Discovery management” 

user who will be the part of Discovery Management RBAC group can do Mailbox-Search operation, for them we don’t need to add Mailbox Search Role into.






Leave a Reply

Your email address will not be published. Required fields are marked *