Contents

Delete Email from User’s Mailbox on O365

You are here:
← All Topics

Steps on how to delete email from user’s mailbox on O365

Add Mailbox Search and Mailbox Import Export Roles to Organization Management Group

New-ManagementRoleAssignment -SecurityGroup "Organization Management" -Role "Mailbox Search"
New-ManagementRoleAssignment -SecurityGroup "Organization Management" -Role "Mailbox Import Export"

Disconnect the existing PowerShell Session for Exchange

#Disconnect existing Exchange Session 
Remove-PSSession $Session

#Reconnect to Exchange / Exchange Online
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ `
-Credential $Credential -Authentication  Basic -AllowRedirection 

Import-PSSession $Session

Search for a particular Email in user’s mailbox

$User = "[email protected]"
$SearchQuery = 'from:"[email protected]"'

Search-Mailbox -Identity $User -SearchQuery $SearchQuery -EstimateResultOnly

Search for a particular Email in user’s mailbox and delete it permanently

$User = "[email protected]"
$SearchQuery = 'from:"[email protected]"'

Search-Mailbox -Identity $User -SearchQuery $SearchQuery -DeleteContent -Force

Search for a particular Email in user’s mailbox and copy to other mailbox for reference

$User = "[email protected]"
$SearchQuery = 'from:"[email protected]"'

Search-Mailbox -Identity $User -SearchQuery $SearchQuery -

Delete Email from User's Mailbox on O365

The Search Query is using Keyword Query Language (KQL) and refer to the following commonly used SearchQuery for reference

# Email send from SENDER
$SearchQuery = 'from:"[email protected]"'
# Email send to RECIPIENT
$SearchQuery = 'to:"[email protected]"'
# Email with subject 
$SearchQuery = 'subject:"important notice"'
# Email with Attachement
$SearchQuery = 'attachment:"xxxx.ppt"'

Commonly used parameter with Search-Mailbox

  • -EstimateResultOnly – Estimation of the totol number of message returned by the search provided
  • -DeleteContent -Force – Delete permanently for the messages return by the search provided in user’s mailbox
  • -TargetMailbox – Destination mailbox where search results are copied
  • -TargetFolder – Folder name in which search results are saved in the target mailbox
  • -LogOnly – Messages returned by the search aren’t copied to the target mailbox.

Refer to Message properties and search operators for In-Place eDiscovery for more information

Reference Links

  1. Manage role groups in Exchange Online

Top Posts & Pages

Leave a Reply

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

Scroll to Top