Closed CSchulz closed 3 months ago
Does source mailbox have FullAccess rights to target mailbox? The script impersonates the source mailbox, so that mailbox needs FullAccess rights to the target for the impersonation to work.
Yes, because it is possible that the source mailbox is able to create new folders. But it seems that the script isn't able to retrieve the WellKnownFolderName bindings.
I have found an interesting point with the permissions. I was expecting giving permissions on highest level is enough, but it seems that I also have to set the permission on each folder (red marked). Isn't it set recursive automatically if I set it on the root element?
Folder permissions won't work in this scenario. FullAccess permissions are needed (https://learn.microsoft.com/en-us/exchange/recipients-in-exchange-online/manage-permissions-for-recipients).
I have just tested this - I can reproduce the issue when I don't have permissions set, but after granting FullAccess the script then works as expected.
Works fine for me as well.
Perhaps you can update the documentation to mention this as well. I have found within another issue the hint about the permissions, but I didn't got that there are differences between folder permissions and mail box permissions.
I have two mailboxes, one works with the mailbox permission update and the other does not work. 🤣
11.06.2024 18:19:01 [MoveItems] Copying from source:\Top of Information Store\Drafts to target:\Oberste Ebene des Informationsspeichers\Entwürfe
11.06.2024 18:19:01 [MoveItems] 14 items found; attempting to copy
11.06.2024 18:19:01 [ThrottledBatchMove] UNEXPECTED ERROR ON MOVE: Ausnahme beim Aufrufen von "CopyItems" mit 3 Argument(en): "The specified target folder could not be found."
I have set the permission like for the other mailbox:
Add-MailboxPermission -Identity target -User source -AccessRights FullAccess -InheritanceType All -AutoMapping $false
EDIT:
It seems like the Draft folder isn't known / mapped correctly.
Using -MergeFolderList @{"Entwürfe" = "Drafts"}
worked.
I'll do some testing for the scenario, it's not one I've tested before. I suspect the script may be targeting one of the WellKnownFolders at the wrong mailbox (from the log, this would be the target mailbox).
For the mailbox where it worked, was the localisation of each of the mailboxes the same? I'm not sure why it would work for one but not another - if the targeting is wrong, I'd expect it to fail consistently (I've only been testing in -WhatIf mode so far).
Here both scenarios:
Source | Target | |
---|---|---|
Entwürfe | Drafts | Worked with WellKnownFolderName |
Drafts | Entwürfe | Worked with with manual mapping |
Some side note, the mailbox had only issues with the Drafts WellKnownFolderName. The others worked directly. Perhaps there is also some issue at our O365 Tenant, I can't explain.
Finally it is working. Thanks for the support and your script!
If it worked for the other WellKnownFolders then the script must be targeting ok (I thought it should be as I did some work quite some time ago to ensure mailbox was included with folder Ids).
If the issue only occurred with one Drafts folder, I suspect mailbox corruption. The Drafts folder is defined by a property on the mailbox root folder (PR_IPM_DRAFTS_ENTRYID) - I have seen this kind of issue when that property is invalid (e.g. the EntryId does not match a folder).
Thanks for confirming - I won't test further unless I get any other reports of issues.
I have two default created mailboxes but with different languages. My wish was to merge automatically WellKnownFolderName.Drafts into WellKnownFolderName.Drafts without caring about the used translation.
Target:![image](https://github.com/David-Barrett-MS/PowerShell-EWS-Scripts/assets/1520593/da3fc444-9956-4491-aceb-294b78c85a88)
Source:![image](https://github.com/David-Barrett-MS/PowerShell-EWS-Scripts/assets/1520593/7d2e387e-8ea0-4863-876d-24174a74d71b)
But the script fails.
I have also tried to use the correct folder names which fails like this:
Also tried to use WellKnownFolderName.Drafts in both cases: