PowerShell on its own won't help you here. You have to leverage some EWS-based solution, such as this one: https://github.com/David-Barrett-MS/PowerShell-EWS-Scripts/wiki/Merge-MailboxFolders.ps1
How to copy / move emails from one mailbox to other using powershell
Prem Kumar Doddi
0
Reputation points
I would like to copy emails from one mailbox to other using powershell
2 answers
Sort by: Most helpful
-
-
Jake Zhang-MSFT 8,700 Reputation points Microsoft Vendor
2025-01-29T08:12:54.0433333+00:00 Hi @Prem Kumar Doddi ,
Welcome to the Microsoft Q&A platform!
Based on your description, to copy or move emails from one mailbox to another using PowerShell, you can use the Search-Mailbox cmdlet. Here are the steps to do this:
- Open PowerShell and run the following command to connect to Exchange Online:
$UserCredential = Get-Credential Connect-ExchangeOnline -UserPrincipalName $UserCredential.UserName -Password $UserCredential.Password
- Make sure the user has the necessary permissions. The user must be a member of the Discovery Management group and be assigned the Mailbox Import Export role.
- Use the Search-Mailbox cmdlet to copy emails from the source mailbox to the target mailbox. Here are examples:
$SourceUserName = "source@example.com" $TargetUserName = "target@example.com" $TargetFolderName = "TargetFolder" Search-Mailbox -Identity $SourceUserName -TargetMailbox $TargetUserName -TargetFolder $TargetFolderName -LogLevel Full
- If you want to move the email (i.e. copy it from the source and then delete it), you can use the -DeleteContent switch:
Search-Mailbox -Identity $SourceUserName -TargetMailbox $TargetUserName -TargetFolder $TargetFolderName -LogLevel Full -DeleteContent
- Check the target mailbox to make sure the email was copied or moved successfully.
Please feel free to contact me for any updates. And if this helps, don't forget to mark it as an answer.
Best,
Jake Zhang