Exchange Powershell Assistance

My boss has asked me to clear contents from users mailboxes that is older than 2 years old.
Is there a powershell command i can run for each user that will do this a little easier than me going into their mailboxes?

Any advice would be greatly appreciated!
tarheelfan0608Asked:
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.

Kyle GreenCommented:
This is not intelligent as it requires you to specify a date range and it choose the emails by the received date. Also keep in mind this is using Search-Mailbox -Identity; it will only work on one mailbox. IF you want to do it to your entire store of mailboxes you'll need to pipe the command through Get-Mailbox and omit the -Identity attribute.

Search-Mailbox -Identity <username> -SearchQuery '(Received:09/20/2012..10/12/2012)' -deletecontent

Open in new window


The effects won't be instantaneous, but you shouldn't have to wait longer than the next sync in Outlook with the server.

If you run into a permissions issue with this, try adding this permission to the mailbox, again I've set it up for one mailbox for you.

Get-mailbox -Identity "USERNAME"| add-mailboxpermission -user administrator -AccessRights FullAccess

Open in new window


Try that and let me know what your results are.
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
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
If your boss asked why we need to play with Shell commands and why not simply apply Retention policy as that will help all along the way :)

Exchange 2010 SP1 Retention Policies
http://www.shudnow.net/2010/04/08/exchange-2010-sp1-retention-policies/

- Rancy
0
tarheelfan0608Author Commented:
Ok silly question if i were to put a retention policy in place. Does the user have to allow it or does it happen automatically?
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Kyle GreenCommented:
Policy is policy, the only way the the average user can circumvent it is by creating a PST and storing their emails on their computer.
0
tarheelfan0608Author Commented:
Ok one more question is it possible to only enable this policy on one of our Mailbox Databases? or does it apply to all?
0
tarheelfan0608Author Commented:
Thank you!
0
Kyle GreenCommented:
You can have different policies for different databases - example: you are a financial institution. You of course would allow your CEO and CIO and CFO much more disk space than your average teller in the branches. Just dive into your settings, I promise the option is there for you. :)
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.