views:

740

answers:

2

Hi,

I've got an issue with using Export-Mailbox cmdlet in Powershell to delete emails between two dates from a mailbox. The current code that I am running is:

Export-Mailbox -Identity mailboxname -StartDate "01/11/2009 00:00:01" -EndDate "14/11/2009 00:00:01" -DeleteContent

I know there are emails that fall between these two dates, but every time the command runs and completes but gives a status message of "Error occurred in the step: Moving messages. Failed to copy messages to the destination mailbox store with error: An unknown error has occured."

Has any had success with using Export-Mailbox to delete messages, or know why this is erroring out?

Thanks.

  • Jonny

~~~ SOLUTION ~~~

Using the help from David I ran the command again as follows:

Get-Mailbox -Identity jonny | Export-Mailbox -TargetMailbox target -TargetFolder folder -EndDate "14/11/09 00:01:00" -StartDate "14/11/09 00:00:00" -DeleteContent

This worked as long as there weren't any more than 3000 emails in that timespan.

+1  A: 

Try:

Get-Mailbox -Identity Jonny | Export-Mailbox -TargetMailbox mailboxname -StartDate "01/11/2009 00:00:01" -EndDate "14/11/2009 00:00:01" -DeleteContent

See this for more info about the most common problems using Export-Mailbox:

The most common problems with using Export-Mailbox are related to permissions. To use Export-Mailbox you need to be delegated the Exchange Server Administrator role, be a member of the local Administrators group for the target server, and have full access to the source and destination mailboxes. The source and destination mailboxes must be in the same Active Directory forest.

These are some common permissions-related errors:

ERROR

  • The specified mailbox database [Mailbox Database Name] does not exist

CAUSE The user running the Export-Mailbox command needs to be delegated the Exchange Administrator role for the Exchange server.

ERROR

  • Error occurred in the step: Creating target folder in the target mailbox. An unknown error has occurred., errorcode: -2147221233

CAUSE The user running the Export-Mailbox does not have full access to the destination mailbox.

ERROR

  • 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”

CAUSE The user running the Export-Mailbox does not have full access to the destination mailbox.

David Glass
Hi David,Thanks for responding. I've just tried it that way, but it has the same effect.
Jonny
Hi David, After much playing around I have got it working! You were correct about the permissions, but what was strange was that I had full access to both mailboxes.However the other reason it was failing was because it was trying to delete too many emails in one go. When I ran it for a shorter time span, for example 1 minute, it worked perfectly!Thanks for your help.
Jonny
A: 

I was also getting below error, I moved source mailbox to another store and it then worked.

•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”

Muzdaf
That's interesting. I might try that, the mailbox itself is currently on it's own store as it is, but I will give this ago.
Jonny