We help IT Professionals succeed at work.

delete all mail for all users in exchange 2010

Is their a way to delete all mail for all users in exchange 2010 SP1. The reason for this is as test I have imported all the mail (through PSTs) from our current domain to the new domain. So would like to delete all the mail and start again .
Comment
Watch Question

Hendrik WieseInformation Security Manager

Commented:
Create a backup mailbox and run the following replacing "MyBackupMailbox" with your backup mailbox name:

Get-Mailbox -Server Server1 -ResultSize Unlimited | Export-Mailbox -IncludeFolders "\Inbox" -StartDate "09/07/2010" -EndDate "09/09/2010" -DeleteContent -TargetMailbox MyBackupMailbox -TargetFolder DeleteMsgs -Confirm:$false

Open in new window

Hendrik WieseInformation Security Manager

Commented:
Or you could try this as well (I have not tested it though):

Get-Mailbox | Export-Mailbox -DeleteContent

Open in new window

CERTIFIED EXPERT

Author

Commented:
Export-mailbox has been removed from exchange 2010 SP1.
Hendrik WieseInformation Security Manager

Commented:
Have you tried, again have not tested it, but let me know if it works?:

Get-Mailbox -Server “your server” | Search-Mailbox -DeleteContent

Open in new window

CERTIFIED EXPERT

Commented:
If ou dont need the public databse content then you can simply delete the DB file.. :)
Solutions Architect
CERTIFIED EXPERT
Commented:
this is what you need
http://www.exchangebytes.com/?p=541
Hendrik WieseInformation Security Manager
Commented:
So you would just need to add -SearchQuery 'Subject:"*"' to my query so that it looks like this:

Get-Mailbox -Server “your server” | Search-Mailbox -SearchQuery 'Subject:"*"' -DeleteContent

Open in new window

Commented:
if I understand you correctly you do not care about the email because you were just doing a test on this new server correct?  if so then

1. Dismount the store/database

2. Delete the database files on disk OR to PRESERVE the old EDB for recovery purposes etc you can simple rename the directory they are located in i.e. if the folder name is Executive your would rename that to OLD-Executive and then recreate the Executive folder.

3. Now go and mount the database

4. Exchange will tell you the files are missing and that if you continue NEW blank/empty database files will be created.

5. Say yes, new DB files are created and mounted and you now have a clean empty database and you will see this when attaching to a mailbox etc.

Commented:
Thanks for the points

Explore More ContentExplore courses, solutions, and other research materials related to this topic.