问题
On 1st July 2020 Microsoft have retired the Search-Mailbox cmdlet. This functionality allowed for the purging of all content in a mailbox e.g.
Search-Mailbox -Identity joe.bloggs@domain.com -DeleteContent
The above functionality worked great, however it has been retired. The recommended way forward is to use New-ComplianceSearch, Start-ComplianceSearch and New-ComplianceSearchAction. This seems all good until you read the documentation at https://docs.microsoft.com/en-us/exchange/policy-and-compliance/ediscovery/delete-messages?view=exchserver-2019 which has this killer line
A maximum of 10 items per mailbox can be removed at once. Because the capability to search for and remove messages is intended to be an incident-response tool, this limit helps ensure that messages are quickly removed from mailboxes. This feature isn't intended to clean up user mailboxes.
I cannot find a way to clean/purge a mailbox now.
Does anyone know of any new PowerShell cmdlets or ways of using existing ones that will allow the complete purging of an Exchange Online mailbox given an Identity (email address)?
回答1:
New-ComplianceSearchAction
can handle 10 email purges at a time. So, you have two options as I can think of
- Loop through many cycles of
New-ComplianceSearchAction -Purge -PurgeType HardDelete
- Apply Retention Policy to the selected mailboxes in which the policy can delete all emails before 'x' number of days
Thanks, Manu
来源:https://stackoverflow.com/questions/62675851/clean-purge-an-exchange-online-mailbox-using-powershell-post-1st-july-2020