Can you delete them manually?
I suspect they may be corrupt in some way and that command cant remove.
I assume it removed all the other items in the sent folder
search-mailbox with -deletecontent parameter not working correctly
Hi,
We have an Exchange Server 2013 and run the following command to export the email in a user's mailbox for a specified date range:
New-MailboxExportRequest -Mailbox <mailbox> -ContentFilter {(received -ge '01/01/2016') -and (received -le '12/31/2018')} -FilePath "UNC-path\export.pst" -BadItemLimit 10
The emails in the mailbox are exported successfully.
We then run the following PowerShell command on the user's mailbox to delete all the emails within the date range:
search-mailbox -identity <identity> -searchquery {(received -ge '01/01/2016') -and (received -le '12/31/2018')} -deletecontent -force
All emails in that date range are deleted except for two emails that still remain in the sent folder of the user's mailbox.
What could be causing the two emails to not be deleted? How, can we ensure that all items in the mailbox within that date range are deleted?
Regards,
4 answers
Sort by: Most helpful
-
Andy David - MVP 147.5K Reputation points MVP
2022-01-20T11:23:28.257+00:00 -
KyleXu-MSFT 26,256 Reputation points
2022-01-21T07:09:38.67+00:00 You can also use the command below to check whether those two emails are contained in the filter:
The command below will return the number of emails that contained in this filter
search-mailbox -identity <identity> -searchquery {(received -ge '01/01/2016') -and (received -le '12/31/2018')} -EstimateResultOnly
If the result does not contain emails, it means you need to filter for those two emails.
One thing you need to notice: The Search-Mailbox cmdlet returns up to 10000 results per mailbox if a search query is specified, the emails that need to be deleted may exceed this limit.
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.
-
Limitless Technology 39,586 Reputation points
2022-01-21T10:02:30.207+00:00 Hello GeorgesCarraha
I would recommend to check the next official article: https://learn.microsoft.com/en-us/exchange/troubleshoot/calendars/cannot-remove-items
Also check for a potential corruption: https://learn.microsoft.com/en-us/previous-versions/tn-archive/aa996773(v=exchg.65)?redirectedfrom=MSDN
and
In case the messages are related to large files:
https://social.technet.microsoft.com/Forums/en-US/b0107b72-13c7-412d-937e-a35194480226/unable-to-delete-large-messages?forum=exchangesvradminlegacy------------------------------------------------------------------------------------------------------------------------------------
--If the reply is helpful, please Upvote and Accept as answer--
-
Andy David - MVP 147.5K Reputation points MVP
2022-01-21T17:10:04.107+00:00 I inspected those two specific emails. When I open the properties, I see that the internet headers section is blank.
and that would make sense if they were in the sent items... no headers for a sent item.