Search Mailbox O365 and delete content in Specific Folder

asif ahamed 201 Reputation points
2022-01-28T19:37:06.587+00:00

Get-mailbox asif.a@keyman .com | Where {$_.Name -match "FolderName"} | search-mailbox -searchquery "Subject:'Citrix'" -EstimateResultOnly
The above cmdlet must search only on the specific folder of the MB instead it searches entire MB. I want to search only on the folderName folder

Same thing below the below cmdlet does not deletes content in the specific folder

Get-mailbox asif.a@keyman .com | Where {$_.Name -match "FolderName"} | search-mailbox -searchquery "Subject:'Citrix'" -DeleteContent

Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
1,895 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,382 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 45,011 Reputation points
    2022-01-28T22:44:46.45+00:00

    Search-Mailbox does just that -- it searches the mailbox.

    1 person found this answer helpful.
    0 comments No comments

  2. asif ahamed 201 Reputation points
    2022-01-30T18:43:40.03+00:00

    No , it does not work. My collogue is tried and it is not working
    Get-mailbox asif.a@keyman .com | Where {$_.Name -match "FolderName"} | search-mailbox -searchquery "Subject:'Citrix'" -DeleteContent
    OnFolderName folder I have only one mail with subject:Citrix but when I execute the the cmdlet and it goes to the entire mb