M
Классика костылестроения search-mailbox more than 10000 result items
Copy and paste the following code into notepad and save it as a .ps1 file. For instance Delete-HugeSpam.ps1
$mbx = get-mailbox "mailboxname here"
Do {
$result = Search-Mailbox -Identity $mbx.Identity -SearchQuery 'Subject:"this is spam from a dirty spammer"' -DeleteContent -force -WarningAction Silentlycontinue
write-host $result.resultitemscount -ForegroundColor Green
} Until ($result.resultitemscount -eq 0)
https://www.exchangeitup.net/2017/01/exchange-search-mailbox-delete-more.html