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

ianmclachlan
ianmclachlan used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Rajul RajInformation Security Officer

Commented:
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

Author

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

Author

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
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Tim EdwardsIT Team Lead - Unified Communications & Collaboration

Commented:
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
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
Tim EdwardsIT Team Lead - Unified Communications & Collaboration

Commented:
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.

Author

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
Tim EdwardsIT Team Lead - Unified Communications & Collaboration

Commented:
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.

Author

Commented:
It worked

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial