Link to home
Start Free TrialLog in
Avatar of Negash
NegashFlag for United States of America

asked on

DeleteContent

I have deleted messages from a mailbox using the following command (search-mailbox -identity xxxxx -SearchQuery "Received:> $('01/01/2013') and Received:< $('12/31/2014')" -DeleteContent  -LogLevel:full -TargetMailbox etest -TargetFolder Admin). This deleted about 12000 messages from the users mailbox in exchange. I renamed the ost file on the users machine and recreated his outlook profile but all those messages that I thought were deleted are still there. Am I not doing it right?
Avatar of Jason Crawford
Jason Crawford
Flag of United States of America image

Remove everything after the -DeleteContent parameter:

search-mailbox -identity xxxxx -SearchQuery "Received:> $('01/01/2013') and Received:< $('12/31/2014')" -DeleteContent

Open in new window

Avatar of timgreen7077
timgreen7077

Have the user to log into OWA and verify if the messages are still present. Also make sure that even though you recreated the outlook profile you care connecting to the new profile and not the old. Make sure you selected the new profile under mail32 in the control panel. See screen shot.

User generated image
Avatar of Negash

ASKER

I actually removed the existing "outlook" profile and created a new one. The messages are present in Webmail/OWA as well.

Per Jason Crawford's suggestion, I removed everything after -DeletedContent parameter to no avail.
The -deletecontent parameter is all you need in order to delete the mail that matches your criteria. Try to write your query like this:

 
search-mailbox -identity xxxxx -SearchQuery received:>01/01/2013, received:<12/31/2014 -DeleteContent

If you choose you can still add the loglevel if you choose. That will not interfere with the delete.
Avatar of Negash

ASKER

I changed the query as you suggested but not items were found to delete.  0 (zero) ResultItemsCount and (0 bytes) ResultItemsSize
DeleteContent.PNG
Ok, so all the items that match that criteria has been deleted it seems. Are you still seeing items in the inbox that match that criteria. i'm sure you have deleted the deleted items bin.
Avatar of Negash

ASKER

Yes, I have deleted the deleted items bin but the items are still there. I compared the mailbox size before and after running the query in exchange and noticed that it has decreased by almost 6GB. Which led me to believe the messages are deleted in exchange. What I don't understand is, how/why they still appear in webmail  and outlook.
Is the mailbox on litigation hold, in place hold or is single item recovery enabled?

Check for single item recovery
Get-Mailbox <Name> | FL SingleItemRecoveryEnabled,RetainDeletedItemsFor

Check for litigation hold
Get-Mailbox <name> | FL LitigationHoldEnabled

Check for In PlaceHold
Get-Mailbox ,name. | FL InPlaceHolds

If the mail is still in the deleted items folder just try to delete it again. there is nothing to stop you from deleting the mail from that folder.

Also check if there are any retention policies applied to the mailbox. If the mail was deleted it should no longer show in OWA.
Avatar of Negash

ASKER

No LitigationHold, InPlaceHold, or retention policy for this mailbox. However,  SingleItemsRecoveryEnabled is True and RetainDeletedItemsFor is set for 30days. Does that mean, once the deleted item retention period expires, those messages will disappear?
ASKER CERTIFIED SOLUTION
Avatar of timgreen7077
timgreen7077

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Negash

ASKER

Thank you!