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
ianmclachlanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rajul RajInformation Security OfficerCommented:
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
0
ianmclachlanAuthor Commented:
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
0
ianmclachlanAuthor Commented:
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
0
Defend Against the Q2 Top Security Threats

Were you aware that overall malware worldwide was down a surprising 42% from Q1'18? Every quarter, the WatchGuard Threat Lab releases an Internet Security Report that analyzes the top threat trends impacting companies worldwide. Learn more by viewing our on-demand webinar today!

Tim EdwardsIT Team Lead - Unified Communications & CollaborationCommented:
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
0
ianmclachlanAuthor Commented:
Hi,

It worked.  I manually ran the folder assistant in powershell and the email has been deleted under that criteria.  It's not a pretty solution, but it works.

IM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tim EdwardsIT Team Lead - Unified Communications & CollaborationCommented:
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.
0
ianmclachlanAuthor Commented:
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
0
Tim EdwardsIT Team Lead - Unified Communications & CollaborationCommented:
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.
0
ianmclachlanAuthor Commented:
It worked
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.