whats the command to delete an email from all mailboxes in exchange 2007 sp2

dougdog
dougdog used Ask the Experts™
on
i need to delete an email from every mailbox
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hendrik WieseInformation Security Manager

Commented:
Export and delete all messages that contain "TEST Subject" in their subject from all mailboxes from the DB1 database to a folder called "TEST DATA" in the Administrator mailbox:

Get-mailbox -database 'DB1' | export-mailbox –SubjectKeywords "TEST Subject" -TargetFolder "TEST DATA" -TargetMailbox Administrator –DeleteContent 

Open in new window


And ensure that you have the correct permission as per the following article: http://www.kevintaber.com/2009/06/09/search-for-and-delete-emails-in-exchange-2007-mailboxes-using-powershell/

Hope this helps!!
Rajkumar DuraisamyIT Service Manager
Top Expert 2012

Commented:
Same as above mentioned command, To search it from all the mailbox and you dont want to have a backup of those emails

Get-mailbox -ResultSize unlimited| export-mailbox –SubjectKeywords "TEST Subject" –DeleteContent

Author

Commented:
is it meant to move all the emails with test subject to a folder in the specified mailbox
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Hendrik WieseInformation Security Manager

Commented:
Yes that is what it does and after it moved all the messages it will delete them. ;)

Author

Commented:
can i get it to not delete them id rather do it manually im afraid of this deleting more data that its mean to

Author

Commented:
i was going to use this command its the only one i can seem to get working

Get-Mailbox -Server EXCHSVR01 | Export-Mailbox -SubjectKeywords “Confidential reports” -StartDate “06/09/2009¿ -DeleteContent
Hendrik WieseInformation Security Manager

Commented:
Then run the command like this to move it to the administrator mailbox

Get-mailbox -database 'DB1' | export-mailbox –SubjectKeywords "TEST Subject" -TargetFolder "TEST DATA" -TargetMailbox Administrator

Author

Commented:
can i have it to run against the server as i have multiple databases
Hendrik WieseInformation Security Manager

Commented:
Try the following:

Get-mailbox -ResultSize unlimited | export-mailbox –SubjectKeywords "TEST Subject" -TargetFolder "TEST DATA" -TargetMailbox Administrator

Author

Commented:
when i run thsi the folder i created remains empty

Author

Commented:
when i run this command it looks like it is deleting loads of mail
im a little worried its deleting more than i t should
Capture.PNG

Author

Commented:
and the test data folder remain empty
Information Security Manager
Commented:
It will only populate the mailbox after the move is completed. Let me know when it is done running.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial