Auto-delete items older than x days for single user mailbox in Exchange 2010

We have a mailbox for which we would like to set up a rule that continually deletes all email older than 7 days. I have come across various powershell commands which show how to do this as a once off, but we need this to run automatically everyday.

As the mailbox is unattended we cannot use Outlook rules and OWA does not offer the required granularity.

What therefore would be the best way of implementing this?

Thanks

JC
mtxitAsked:
Who is Participating?
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.

Chris MillardCommented:
You need to create a retention policy tag followed by a retention policy which you can then assign to the user(s) concerned.

I did this just last week (except that mine deletes after 30 days) following this article:-

https://ibenna.wordpress.com/2013/02/04/exchange-2010-retention-policy-to-clear-deleted-items/
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
MAS (MVE)EE Solution GuideCommented:
You can run using Windows Schedule tasks.
1. Save your command as PS1 file (powershell file). Save it as .ps1

2. Create a batch file by copying the below command and modify where you put your powershell file. Save as .bat

powershell -command "&{C:\Temp\Monitoring\test-exchangeServerHealth.ps1}"

3. Create a windows schedule task to run the batch file every 2 hours

Here is the reference
http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_28651103.html


Or
create a retention policy and tag this user
0
Will SzymkowskiSenior Solution ArchitectCommented:
As stated you can use Retension Tags for a individual mailbox or you can use Search-Mailbox using the -deletecontent switch. Below is the syntax for the search-mailbox script.

Script is below...
Provide the account with Import-Export Management Role
New-ManagementRoleAssignment -Role "Mailbox Import Export" -User Administrator

Open in new window


Script to deleted the mailbox content
$date = get-date
Search-Mailbox -Identity mailbox1 -StartDate $date.AddDays(-7) -EndDate $date.AddDays(-365) -deletecontent

Open in new window


You would then run this from a scheduled task for how often you want this to perform the remove of the mail items.

Because you are only looking to do this for everything older than 7 days you should only have to run this once a day.

Will.
0
Murali ReddyExchange ExpertCommented:
I'd suggest retention policy would be the best and easiest approach.
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
Exchange

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.