Forum Discussion
Freshie
Aug 09, 2024Copper Contributor
Power Shell Script to move mail between mailboxes (ON PREM)
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
- You have several options: the Search-Mailbox cmdlet (https://learn.microsoft.com/en-us/powershell/module/exchange/search-mailbox?view=exchange-ps); an EWS-based solution (for example https://github.com/David-Barrett-MS/PowerShell-EWS-Scripts/blob/master/Legacy/Merge-MailboxFolder.ps1), export/import as PST; third-party tools.
- FreshieCopper Contributor
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 -DeleteContentBut 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.comThere 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.comI 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.