Avatar of ianmclachlan
ianmclachlan
 asked on

Exchange 2010 - Powershell to delete specific content per folder by date

Hi Guys,

Anyone got a PS script that will allow me to delete specific content for a users mailbox.  ie.  "I want to delete everything up to 2016 from the sent items folder for user joe bloggs".  I have been playing around with the search-mailbox function, but I'm struggling with the syntaxt of defining a particualar folder.  I can remove ALL mail by date, I just need to define from which folder I want the criteria to remove.

Thanks for your help guys.

IM
PowershellExchangeEmail Servers

Avatar of undefined
Last Comment
ianmclachlan

8/22/2022 - Mon
Rajul Raj

Below link will be usefull. It has nice writeup for your query

https://www.petri.com/delete-email-from-microsoft-exchange-user-mailboxes-using-powershell
ianmclachlan

ASKER
Hi Rajul Raj,

Thanks for your comments.  I'm up to speed with this method.  However, it doesn't explain how you filter by folders ie "Sent items" or "inbox" etc..  I want to remove ALL email from the "sent items" folder up to 2016.  So, I don't want any other emails being selected/removed, I just want the selection to be concentrated on the "sent items" folder only.

Hope that makes sense.

Thanks,

IM
ianmclachlan

ASKER
Hi Guys,

I don't think it's possible.  As a way around this is:  I have created a retention policy tag to delete last 6 months of email from sent items.  I created a retention policy and applied the tag and applied the mailbox.  Once the folder-assistant runs it should remove the email ... I hope.

Will keep you posted

IM
Your help has saved me hundreds of hours of internet surfing.
fblack61
Tim Edwards

It all depends on how you setup your tag, this is the correct method of doing this.

If you setup them up to delete and recovery they will go into your delete items recovery folder, depending on your days to purge this you can add that onto when they get removed before they are actually purged.

You can verify that that the tag has been applied by going to your older sent items as they should have a date when the item expires
ASKER CERTIFIED SOLUTION
ianmclachlan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Tim Edwards

It is only good if you want to do organization wide and have a policy in place, but for a one off request it is not the best way of doing it.
ianmclachlan

ASKER
It's used for road warriors who use ipads and/or OWA.  Without Outlook, I've never found an efficient method of archiving/removing old/unwanted email.  Perhaps, you could enlighten me as to the correct method?

IM
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Tim Edwards

For archiving you could always setup an archive database, same thing you can create the policies to automatically do it as well the user can setup archive rules on their outlook.
ianmclachlan

ASKER
It worked