Limitation on number of emails to be deleted via New-ComplianceSearchAction

Chingis Rustemov 21 Reputation points
2022-05-16T13:30:37.893+00:00

Hello

Is there any limitation on number of emails which can be deleted by New-ComplianceSearchAction?What I have noticed with SoftDelete is that it can work only on 10 e,ails, and if the number exceeds it the code do nothing. I use this command: New-ComplianceSearchAction -SearchName "all" -Purge -PurgeType SoftDelete

P.S. The same with HardDelete.

Is there a way to delete a bulk of emails of a user with PowerShell in Exchange Online?

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,849 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,851 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 116.7K Reputation points MVP
    2022-05-16T14:03:54.753+00:00

    You've already found the limitation, there's no way around it. If you need to delete more than 10 items, run additional instances of New-ComplianceSearchAction. Or use the good old Search-Mailbox cmdlet.

    1 person found this answer helpful.

  2. Joyce Shen - MSFT 16,696 Reputation points
    2022-05-17T02:35:35.427+00:00

    Hi @Chingis Rustemov

    Yes, considering that the recoverable items folder play an essitial role in preserving data for mailboxes on hold, normally it's recommended to use the New-ComplianceSearchAction cmdlet which has a limit of 10 items at one time to lower the potential impact of mistakes.

    If you insist on deleting more than 10 items at a time, you can use the Search-Mailbox cmdlet instead. The example below searchs and deletes the items received in the last three months from user1's recoverable items folder:

     Search-Mailbox -Identity user1 -SearchDumpsterOnly -SearchQuery {Received:"2020/5/22..2020/8/24"} -EstimateResultOnly  
     Search-Mailbox -Identity user1 -SearchDumpsterOnly -SearchQuery {Received:"2020/5/22..2020/8/24"} -DeleteContent  
    

    202524-image.png

    And here is a script to purge messages from Exchange Online using an Office 365 content search and a purge action applied to the results of that search.

    For more related information:
    How to Run Microsoft 365 Content Searches to Purge Exchange Online Messages
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.

    Is there a way to delete more than 10 items at a time from the RecoverableItems folder?


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    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.


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.