Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell script to delete old mail items from exchange 2k3

Posted on 2010-08-17
3
Medium Priority
?
1,626 Views
Last Modified: 2012-05-10
Hello everyone,

I was hoping to get some help writing a powershell script that do the following:

1) Connect to exchange 2k3 (with latest SP installed).
2) Gain access to mailboxes (either individual or bulk mailboxes)
3) Look for mail items that are older than "x" amount of days
4) Once it finds mail items are that older than the specified date, go ahead and delete those mail items.

Exchange is running on win2k3 with latest SP. I'm also using PS 2.0 CPT 3.  Not sure if this can be done with exchange 2k3, but it's worth the try for me as we are getting ready for a email migration and trying to remove Enterprise Vault archiving solution icons/shortcuts from users mailbox.

Please let me know if you have any questions, or if there's anything that isn't clear.

Thanks in advance.
0
Comment
Question by:bloodywicked
[X]
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 Comments
 
LVL 32

Assisted Solution

by:endital1097
endital1097 earned 200 total points
ID: 33457701
i think you are looking for something like this
http://support.microsoft.com/kb/319188
0
 
LVL 4

Accepted Solution

by:
mukulag earned 1800 total points
ID: 33463267
# Delete content from user's mailbox depending upon the criteria

Get-Mailbox -Server ServerMbx1 -resultsize unlimited | Export-Mailbox -DeleteContent -EndDate 10/08/2009 -IncludeFolders "\Inbox"
 
The above command will delete all emails from ALL mailboxes on ServerMbx1. Be careful when you do this as the results are irreversible. I would recommend to run the above command against a specific mailbox first as below:
Get-Mailbox -MAILBOXNAME | Export-Mailbox -DeleteContent -EndDate 10/08/2009 -IncludeFolders "\Inbox"

 
0
 

Author Closing Comment

by:bloodywicked
ID: 33534853
exactally what i was looking for.

thank you all.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

A couple of months ago we ran into an issue that necessitated re-creating our Edge Subscriptions. However, when we attempted to execute the command: New-EdgeSubscription -filename C:\NewEdgeSub_01.xml we received an error indicating that the LDAP se…
Are you an Exchange administrator employed with an organization? And, have you encountered a corrupt Exchange database due to which you are not able to open its EDB file. This article will explain all the steps to repair corrupt Exchange database.
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

721 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