Link to home
Start Free TrialLog in
Avatar of pramod1
pramod1Flag for United States of America

asked on

exchange, outlook

I ran one script yesterday to delete emails with particular subject name  from a particular database , it did run

Get-Mailbox -Database " Mailbox Database"| Export-Mailbox -SenderKeywords "re:expense report" -DeleteContent

but few users had this event 1008 REPORTED on exchange 2007 application logs

export-mail box task for mailbox " user name)

error: failed to copy messages to the destination mailbox store with error:

MAPI or inspecified service provider
ID no: 00000000-0000-00000000
Avatar of Ganesh Anand
Ganesh Anand
Flag of Bahrain image

I assume you have Exchange 2010 or above.

To Remove specific mail from server for all users.
C:\>Get-Mailboxdatabase
Note all the databases homed on which server

Set permissions for all mailboxes to remove message:
[PS] C:\>Get-mailbox -Database DBName| add-mailboxpermission -user adminuseraccount -AccessRights FullAccess

You need search-mailbox cmdlet from below snapin
[PS] C:\>Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010

Remove the mail using subject and sender can include date and time as well
[PS] C:\>Get-Mailbox -Server "servername" | Search-Mailbox -SearchQuery 'Subject:"Christmas Party" AND From:circular@domain.com' –DeleteContent

If you have enabled copy content destination and tried you might have got the error for the mailbox which you did not have permission.
Avatar of pramod1

ASKER

I am using exchange 2007, how should I disable content destination

or do I need to modify below one
Get-Mailbox -Database " Mailbox Database"| Export-Mailbox -SenderKeywords "re:expense report" -DeleteContent
You can use without setting up destination and delete directly from the mailbox. But remember this, the mobile devices are faster than outlook receiving mails. When you are removing, it should be instant, but chances are high that user receives in mobile device.
Avatar of pramod1

ASKER

that  is fine ganesh, what command should I run on exchange 2007 now.
can you modify below:

Get-Mailbox -Database " Mailbox Database"| Export-Mailbox -SenderKeywords "re:expense report" -DeleteContent
ASKER CERTIFIED SOLUTION
Avatar of Ganesh Anand
Ganesh Anand
Flag of Bahrain 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
Avatar of pramod1

ASKER

but can it run on exchange 2007
Yes it will run