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

i need to delete an email from every mailbox
LVL 1
dougdogAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Hendrik WieseInformation Security ManagerCommented:
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!!
0
Rajkumar-MCITPCommented:
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
0
dougdogAuthor Commented:
is it meant to move all the emails with test subject to a folder in the specified mailbox
0
Discover the Answer to Productive IT

Discover app within WatchGuard's Wi-Fi Cloud helps you optimize W-Fi user experience with the most complete set of visibility, troubleshooting, and network health features. Quickly pinpointing network problems will lead to more happy users and most importantly, productive IT.

Hendrik WieseInformation Security ManagerCommented:
Yes that is what it does and after it moved all the messages it will delete them. ;)
0
dougdogAuthor 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
0
dougdogAuthor 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
0
Hendrik WieseInformation Security ManagerCommented:
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
0
dougdogAuthor Commented:
can i have it to run against the server as i have multiple databases
0
Hendrik WieseInformation Security ManagerCommented:
Try the following:

Get-mailbox -ResultSize unlimited | export-mailbox –SubjectKeywords "TEST Subject" -TargetFolder "TEST DATA" -TargetMailbox Administrator
0
dougdogAuthor Commented:
when i run thsi the folder i created remains empty
0
dougdogAuthor 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
0
dougdogAuthor Commented:
and the test data folder remain empty
0
Hendrik WieseInformation Security ManagerCommented:
It will only populate the mailbox after the move is completed. Let me know when it is done running.
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
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
Networking

From novice to tech pro — start learning today.