Merge-Mailboxfolder Impersonation error
Hi David,
Thanks for creating this script to move mails from mailbox to mailbox. I have tried using this but encountered the errors below:
Merge-MailboxFolder.ps1 version 1.1.9 starting VERBOSE: Loading Microsoft.Exchange.WebServices.dll vSystem.Object[] found at: System.Object[] Using EWS Managed API found at: C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll
Processing mailbox [email protected] VERBOSE: Using default credentials VERBOSE: Currently caching 1 ExchangeService objects VERBOSE: [ThrottledFolderBind]Attempting to bind to folder MsgFolderRoot ([email protected]) Error (ThrottledFolderBind): Exception calling "Bind" with "3" argument(s): "The request failed. The remote server retur ned an error: (401) Unauthorized." VERBOSE: FAILED to bind to folder MsgFolderRoot ([email protected]) Failed to open source message store ([email protected]) Please check that you have impersonation permissions
I have confirmed that the user running has ApplicationImpersonation rights. Is there any other place that I should check?
Is this against Exchange Online? What parameters are you using when calling the script? Unauthorized means just that, so it's just a case of working out why. For Exchange Online, if MFA is enabled on a mailbox then you'd need to use OAuth to log-on (and would get an auth error otherwise).
Hi David,
Thanks for replying. This is against on prem Exchange 2013.
The parameters that I am using are .\Merge-MailBoxFolder.ps1 -sourcemailbox [email protected] -targetmailbox [email protected] -mergefolderlist inbox,"sent items" -searchfilter received:$archivedate -processsubfolders -EWSUrl "https://mail.test.com/EWS/Exchange.asmx" -createtargetfolder -LogFile $log -impersonate -verbose
This is run using an archive user who has impersonation rights.
I have checked by trying to login as the archive user to the target mailbox and it works. No MFA is turned on.