Link to home
Start Free TrialLog in
Avatar of Gospodin Rasputin
Gospodin Rasputin

asked on

Deleting an e-mail sent to all users from exchange 2007

Someone has just mistakenly sent an e-mail to all users. Is there anyway I can remove all unread copies of this e-mail before the weekend is over?

I know I could attempt to reacall/replace the e-mail, but I'm afraid this depends on the recipient agreeing to the recall. Is there a way my Exchange admins can remove this message from the Exchange Information Store using the message ID?

Thanks
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

You can use the Export-Mailbox cmdlet to accomplish this. See the below script...
Get-Mialbox -ResultSize "Unlimited" |
Export-Mailbox -PSTFolderPath "C:\pstfiles\filename.pst" -BadItemLimit 1000000 -ContentKeywords "CLICK HERE TO Upgrade" -DeleteContent -Confirm:$false

Open in new window


The above script will get all mailboxes and export the results to a pst file and delete the email from all of the mailboxes where "Click Here To Upgrade" is in the body or the subject line.

Will.
In 2007, you can use export-mailbox cmd let to search and delete specific email. Here is MS KB with all required steps:
http://blogs.technet.com/b/exchange/archive/2010/10/27/3411398.aspx
Avatar of Gospodin Rasputin
Gospodin Rasputin

ASKER

Hi Amit,
I'm using the following but it seems to be complaning because I have not specified thethe target mailbox.

Get-Mailbox -ResultSize Unlimited | Export-Mailbox -ContentKeywords "REC_2999.wmv" -StartDate "15/06/2010" -EndDate "18/06/2010" -DeleteContent

But I wish to just remove the message without copying it to anywhere else.

Any idea? I suspect maybe I should remove the |Export -Mailbox from the command.

The error I get on all the mailboxes is as follows:

Export-Mailbox : Error was found for Udojil Alexander (Udojil.Alexander@mydomain.o
rg.uk) because: Error occurred in the step: Moving messages. Failed to copy messages to the destination mailbox store with error:
MAPI or an unspecified service provider.
ID no: 00000000-0000-00000000, error code: -1056749164
At line:1 char:51
+ Get-Mailbox -ResultSize Unlimited | Export-Mailbox <<<<  -ContentKeywords "RE
C_2999.wmv" -StartDate "15/06/2010" -EndDate "18/06/2010" -DeleteContent
    + CategoryInfo          : InvalidOperation: (540:Int32) [Export-Mailbox],
   RecipientTaskException
    + FullyQualifiedErrorId : E05CA502,Microsoft.Exchange.Management.Recipient
   Tasks.ExportMailbox
In 2007 that was the limitation, which is removed in 2010 or above. You need to provide target mailbox. You can create or use test mailbox as target mailbox. Later, you can clean up target mailbox.
What should the name of the target mailbox be? What format? The usernames format? Not exactly sure how mailbox is names in Exchange 2007...will try the username format and see.
Thank you
It is not a requirement for a mailbox. You can use just use a PST file instead, as I have illustrated in my first post.

Will.
As Will said, use PST. Either mailbox or PST you need to export it somewhere in 2007.
Tried to specify target mailbox and it is telling me the source and target are the same.

I thought the cmd searches for any messages marching the criteria and deletes it. Does it search in the target mailbox only!!
My Command is : Get-Mailbox -ResultSize Unlimited | Export-Mailbox -ContentKeywords "REC_2999.wmv" -TargetMailbox TEST -TargetFolder 'DeleteMsg' -DeleteContent

The new error message is:
Export-Mailbox : The source mailbox 'Test' and target mailbox 'Test' are the same, and is not supported by this command.
At line:1 char:51
+ Get-Mailbox -ResultSize Unlimited | Export-Mailbox <<<<  -ContentKeywords "RE
C_0002.wmv" -TargetMailbox Test -TargetFolder 'DeleteMsg' -DeleteContent
    + CategoryInfo          : InvalidArgument: (155:Int32) [Export-Mailbox], R
   ecipientTaskException
    + FullyQualifiedErrorId : B7EE2B39,Microsoft.Exchange.Management.Recipient
   Tasks.ExportMailbox
Just use a the -PSTFolderPath switch. You cannot use the same mailbox as the Target mailbox.

Will.
OK Will. I'll try that and let you know.
Thanks for your help.
Because it searching the Test mailbox too, when you have not specified in the filter, just exempt it.

Makwe sure you aslways specify a date range, otherwise the command deletes any old messages matching the subjected criteria.

Something like..

Get-Mailbox -ResultSize Unlimited |Where-Object {!($_.Alias -eq "Test")} |Export-Mailbox -ContentKeywords "REC_2999.wmv" -StartDate "15/06/2010" -EndDate "18/06/2010" -TargetMailbox TEST -TargetFolder 'DeleteMsg' -DeleteContent
I assume you got the answer already. You need to exclude this mailbox.
Hi Will,
Please can you expand your command for me. I am trying to search all the inbox in my information store for a mesage titled "REC_2999.wmv" and delete them all.

In your command, is -PSTFolderPath "C:\pstfiles\filename.pst" the source where you are deleting from or the destination (target folder where you are deleting to?

I just looked at your command and it confused me now, maybe

Thank you
Hi Will/ Amit,
When I use the -PSTFolderPath switch, it complains about me using a 64bit system and the command being for 32bit system with outlook 2003 installed in it.

Any other suggestions?
Thank you
In Exchange 2007 this is another limitation as you will need to use a 32bit workstation to export the items to a PST file. Use a 32bit client machine.

Will.
And on a 32bit client machine, how do I run the Exchange shell?
I was running these commands on the Exchange 2007n Server.
Thank you
You need to install the 32bit Management Tools for Exchange 2007.  Once you have that installed you will be able to export to PST with no issues.

Will.
Where do i install this tool? On the exchange Server or ona workstation.
Thank you
ASKER CERTIFIED SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Will,
I shall try this and let you know.
Thanks