New-ComplianceSearch in specific folder in mailbox?

Bryan Folmsbee 1 Reputation point
2022-04-25T00:58:20.017+00:00

Hello,

I need to delete all emails from X sender in specific folders in a user's email (e.g. Archive, but not Inbox). How can I specify the specific folder in the mailbox to delete from? I am using New-ComplianceSearch PowerShell function for Exchange Online. I am able to delete from all folders, but I can't do that.

Also, the main issue is the majority of emails (96/100GB) are on the Online Archive from Microsoft. I would really need to be specifying that.

Is there any way to do this?

`
$Search=New-ComplianceSearch -Name "<name>" -ExchangeLocation <recip email> -ContentMatchQuery '(From:"<send email>")'

Start-ComplianceSearch -Identity $Search.Identity

New-ComplianceSearchAction -SearchName "$Search" -Purge -PurgeType <Soft/Hard>Delete
`
Thank you

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,609 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,563 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Kael Yao-MSFT 37,651 Reputation points Microsoft Vendor
    2022-04-25T03:09:41.723+00:00

    Hi @Bryan Folmsbee

    Here is a link with detailed information on this topic for your reference: Use Content search for targeted collections
    In short, you may specify folder by using folder ID in the Search.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Limitless Technology 39,686 Reputation points
    2022-04-26T15:23:16.05+00:00

    Hi there,

    You can try the Perform eDiscovery against specific folders only. We have an option to do so, via the so-called targetted collections. In a nutshell, you provide the binary-encoded folderId and use it as you would use any other search property

    Here is a link for a detailed description of the process that you must follow.

    Use Content search for targeted collections https://learn.microsoft.com/en-us/microsoft-365/compliance/use-content-search-for-targeted-collections?view=o365-worldwide

    Perform eDiscovery against specific folders only https://techcommunity.microsoft.com/t5/security-compliance-and-identity/perform-ediscovery-against-specific-folders-only/m-p/75600

    ----------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.