Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Delete emails from users Inboxes

Posted on 2011-05-08
Medium Priority
Last Modified: 2012-05-11

This morning, an email went out to a whole bunch of people that shouldn't have! HR and management have now asked us if there's a way to remove the message from users' mailboxes before Monday morning. There are hundreds of mailboxes, so going into each one is not an option...any idea? We have the sender, recipient, and subject of this offending message.

Running Exchange 2007 SP2.
Question by:digitalco
  • 3
  • 3

Author Comment

ID: 35716802
Thanks...so reading around I would use this command below:

Get-Mailbox -Database DB1 | Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder VirusData -SubjectKeywords "Virus message" -DeleteContentDo you know how I would use this command if I had the users in a text/CSV file?

Also, does this work on one mailbox at a time, or can do multiple?

Accepted Solution

Camy earned 2000 total points
ID: 35716928
If you are just deleting you dont need the targetfolder, etc

Get-Mailbox -Database DB1 | Export-Mailbox -SubjectKeywords "Virus message" -DeleteContent

This would get all mailboxes in that database, and delete messages with that subject.
To read in from a text file you could do something like:

Get-Content c:\users.txt | Foreach-Object {Get-User $_ |  Export-Mailbox -SubjectKeywords "Virus message" -DeleteContent}

Dont think that's quite right and cant test at the moment (due to time & wine  :) ) but might get you closer...
Obviously worth testing before you run it.. even against your own mailbox rather than hundreds of users.
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.


Expert Comment

ID: 35717298
ExMerge is a tool from Exchange 2003 but works on 2007 also


Author Comment

ID: 35724485
How about:

Get-Content c:\users.txt | Get-Mailbox | Export-Mailbox -SubjectKeywords "Virus message" -DeleteContent

Author Comment

ID: 35758686
?? Anyone - and is there a way I can see a log of how we're progressing?

Expert Comment

ID: 35771240
What you wrote there looks about right - did you test and find that it didnt work?

More information / confirmation of method - http://msexchangeguru.com/2011/05/06/delete-email/

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes Top 9 Exchange troubleshooting utilities that every Exchange Administrator should know. Most of the utilities are available free of cost. List of tools that I am going to explain in this article are:   Microsoft Remote Con…
This article will help to fix the below errors for MS Exchange Server 2016 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

577 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