Closed danno2021 closed 1 year ago
You need to configure an application in Azure AD for the OAuth part, please see https://github.com/David-Barrett-MS/PowerShell-EWS-Scripts/wiki/Exchange-Online-OAuth-Configuration
(Get-Credential) will no longer work with Exchange Online because basic auth is now deprecated.
Folder path supports normal syntax (and can start with WellKnownFolderName). If no well known folder included, the path starts from Top of Information Store.
I followed the steps to add the authentication parameters as explained in https://github.com/David-Barrett-MS/PowerShell-EWS-Scripts/wiki/Exchange-Online-OAuth-Configuration but I'm getting this error:
Processing mailbox
Edited comment above - it was missing key info.
.\Merge-MailboxFolder.ps1 -Copy -WhatIf -SourceMailbox Ekun@E-ssentially.com -TargetMailbox SpecMBXshared11@E-ssentially.com -MergeFolderList @{"WellKnownFolderName.Inbox"= "Inbox"; "WellKnownFolderName.SentItems"= "Sent Items"} -ProcessSubfolders -CreateTargetFolder -Office365 -OAuth -OAuthClientId "e3b3c4df-e041-4613-a66d-535309299948" -OAuthTenantId "01088aa4-1bdc-42ad-a76a-17ef028779fc"
Recently came across this script. I am struggling with the use of OAuth. Can you confirm my syntax is correct. I get a prompt with my O365 name and password. After that i get a permissions request box. Immediately after i accept that, i get the message below;
The machine i am running the script on is running Exchange 2013 on Windows 2008R. I am using this server because i could not get the Microsoft.Exchange.WebServices.dll to register correctly on my Windows 10 machine. Could it be linked to the RedirectURL (http://localhost/code) - as the machine is already running IIS?
For the AutoDiscover error, you can avoid that by using -Office365 switch (autodiscover is not needed for Exchange Online as there is a single EWS endpoint). You could also use the -AllowInsecureRedirection switch with the script to allow it to follow the redirection (which per the log, is to Office 365 so is expected).
Some background on this:
A nasty bug that Microsoft refuses to fix (they deem it to be 'by design'): Can't use Outlook to move a folder tree (a folder that contains subfolders) from one folder to another in a Shared Mailbox. Get the bogus error 'cannot move/copy folder because it may contain private items'. OWA can't be used because the folder structure on the source/target mailbox is hierarchical and complex. When it prompts with the target, it does an 'expand all' on the folders and it's impossible to locate the folder among thousands of nested folders - no option to avoid the 'expand all' or 'collapse' the folder list.
2 issues: 1) I've tried every possible combination of authentication parameters ('-oauth', '-office365' with or without 'credential (get-credential)', etc. I'm already logged into the MS acct associated with the mailboxes. I either get 'Failed to obtain OAuth token', or 'Error (ThrottledFolderBind): Exception calling "Bind" with "3" argument(s): "The request failed. The remote server returned an error: (401) Unauthorized." Failed to open source message store (mailbox@domain.com) 2) How to specify folder path? The path is not a 'wellknownfoldername'. I tried using a folder path I've used successfully with VBA code: "\\\, but I don't know if that's the proper syntax - can't determine because blocked with the above authentication errors.