Power Shell Script to move mail between mailboxes (ON PREM)

Copper Contributor

Hi,

I have a mailbox with about 1.3M messages I need moved to a different mailbox. I tried using Outlook rules, but it was too much volume and kept crashing.

If anybody can help me with this script I would appreciate it.

Thanks,

Jeffrey

3 Replies

@VasilMichev 

Hi,
I found a script which should do the trick:

 

New-ManagementRoleAssignment -Role "Mailbox Import Export" -User "username"
$sourceMailbox = "email address removed for privacy reasons"
$targetMailbox = "email address removed for privacy reasons"
Search-Mailbox -Identity $sourceMailbox -TargetMailbox $targetMailbox -TargetFolder "InBox" -LogLevel Full -DeleteContent

 

But it is erroring out:
Move/Copy messages failed.
+ CategoryInfo : ReadError: (0:Int32) [Search-Mailbox], QuotaExceededException
+ FullyQualifiedErrorId : [Server=FMMBX10,RequestId=396ede4d-f5da-4129-add3-b22557db1fd0,TimeStamp=8/9/2024 2:20:0
3 PM] [FailureCategory=Cmdlet-QuotaExceededException] 6599EB7,Microsoft.Exchange.Management.Tasks.SearchMailbox
+ PSComputerName : fmmbx10.domain.com

There was an Exception when creating the log file.
+ CategoryInfo : InvalidArgument: (:) [], SearchLogFileCreateException
+ FullyQualifiedErrorId : [Server=FMMBX10,RequestId=396ede4d-f5da-4129-add3-b22557db1fd0,TimeStamp=8/9/2024 2:20:0
5 PM] [FailureCategory=Cmdlet-SearchLogFileCreateException] 2F8D988A
+ PSComputerName : fmmbx10.domain.com

 

I believe it is exceeding the quota of 10,000 messages. How could I modify thew script to allow unlimited messages. There are currently 1.3M messages I am trying to move between the 2 boxes.

Thanks,

Jeffrey

You'll have to run it multiple times.