MS Exchange 2007 Powershell script to delete emails on all mailboxes older than a date i specify

Posted on 2010-11-16
Last Modified: 2012-06-27
My boss has handed me a task to cleanup soem emails on our server. Thsi si something for the moment that i do not want ot automate.  I have read the articles about the Managed folders and will implement this at a alter date.  What i am tryign to find is a powershell script for MS exchange 2007 SP1 that i can run that will look at all mailboxes and delete ANY email, calendar item and such over 3 years old.  Can anyone help i have been searchign for hours with no luck.

Don C
Question by:donnyiris
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Expert Comment

ID: 34147420
Here's something I found from
Get-Mailbox -Server Server1 -ResultSize Unlimited | Export-Mailbox -SubjectKeywords "Friday Party" -IncludeFolders "\Inbox" -StartDate "09/07/2010" -EndDate "09/09/2010" -DeleteContent -TargetMailbox MyBackupMailbox -TargetFolder DeleteMsgs -Confirm:$fals

Open in new window

LVL 26

Accepted Solution

Tony Johncock earned 250 total points
ID: 34147442
export-mailbox Administrator -PSTFolderPath C:\temp\ -DeleteContent -endDate 11/30/2009

This command actually exports them to a PST rather than simply deleting them which means you could restore them if required.

Author Comment

ID: 34147586
Will that doo all mailboxes?
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.


Assisted Solution

fred3rd earned 250 total points
ID: 34147861
If the question is for me, then yes, it will do all mailboxes.

Author Comment

ID: 34148242
That command only does Administrator this does everything on the server before this date and only validates figured id post it.

Get-Mailbox -Server YourMailServerName| Export-Mailbox -PSTFolderPath H:\temp\ -EndDate "09/30/2007 12:01:00" -DeleteContent -validateonly

Expert Comment

ID: 34148311
Both Tony and I combined to give Donny his command. He should give either one of us the points.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
Check out this step-by-step guide for using the newly updated Experts Exchange mobile app—released on May 30.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question