PowerShell-EWS-Scripts icon indicating copy to clipboard operation
PowerShell-EWS-Scripts copied to clipboard

What to do with uncopied files?

Open Leni-Vietz opened this issue 1 year ago • 3 comments

Hi,

first of all - thank you for this marvellous script. Really helps with users without self-mailbox-control ;)

I'm copying a emails with the following command:

$src = "[email protected]"
$dst = "[email protected]"
$start = "12/31/2020"
$end = "01/01/2022"
.\Merge-MailboxFolder.ps1 -SourceMailbox $src -TargetMailbox $dst -OnlyItemsCreatedAfter $start -OnlyItemsCreatedBefore $end -SourceArchive -CreateTargetFolder -ProcessSubfolders -Office365 -OAuth -OAuthTenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

and I get the following:

08.02.2024 15:10:25 [MoveItems] [MoveItems]Moving from [email protected]:\Folder nadrzędny magazynu informacji\Elementy wysłane to [email protected]:
\Top of Information Store\Elementy wysłane
**08.02.2024 15:10:26 [MoveItems] 2534 items found; attempting to move**
08.02.2024 15:12:06 [RemoveProcessedItemsFromList] No results returned - assuming all items processed
(...)
08.02.2024 18:09:10 [Merge-MailboxFolder.ps1] Script finished in 02:59:03.7367093

No matter how many times I run the script there are still those 2534 items. Is there any workaround or parameters to add to deal with this? :)

Leni-Vietz avatar Feb 08 '24 21:02 Leni-Vietz

I suspect the issue is that you are trying to copy from the archive mailbox of one user to the primary mailbox of another. Does it work from primary to primary? Note thatin this scenario, the authenticating account needs FullAccess permission to both mailboxes (or if impersonating the source, the source mailbox needs FullAccess permission to the target).

David-Barrett-MS avatar Feb 08 '24 22:02 David-Barrett-MS

The user has access FullAccess to [email protected] and my account from which I run the scripts has access to both his and the 2021 archive.

Would it be a workaround to disable archiving of old messages for [email protected]. Move the messages from archive of [email protected] to the main mailbox and then move from non-archive to [email protected]?

PS C:\Users\user\scripts> Get-EXOMailboxPermission [email protected]


Identity        : Archiwum 2021 mailbox20221115084334
User            : NT AUTHORITY\SELF
AccessRights    : {FullAccess, ReadPermission}
IsInherited     : False
Deny            : False
InheritanceType : None

Identity        : Archiwum 2021 mailbox20221115084334
User            : NT AUTHORITY\SELF
AccessRights    : {FullAccess, ExternalAccount, ReadPermission}
IsInherited     : False
Deny            : False
InheritanceType : Descendents

Identity        : Archiwum 2021 mailbox20221115084334
User            : [email protected]
AccessRights    : {FullAccess}
IsInherited     : False
Deny            : False
InheritanceType : All

Identity        : Archiwum 2021 mailbox20221115084334
User            : [email protected]
AccessRights    : {FullAccess}
IsInherited     : False
Deny            : False
InheritanceType : All




PS C:\Users\user\scripts> Get-EXOMailboxPermission [email protected]


Identity        : mailbox
User            : NT AUTHORITY\SELF
AccessRights    : {FullAccess, ReadPermission}
IsInherited     : False
Deny            : False
InheritanceType : All

Identity        : mailbox
User            : [email protected]
AccessRights    : {FullAccess}
IsInherited     : False
Deny            : False
InheritanceType : All

Leni-Vietz avatar Feb 09 '24 13:02 Leni-Vietz

I also tried using the -Impersonate parameter and it didn't change the outcome.

Leni-Vietz avatar Feb 14 '24 12:02 Leni-Vietz

I didn't get a chance to look into this until recently, but I can confirm that copying from one user's archive mailbox to another is not supported in EWS. You'll need to move items via a primary mailbox (so your workaround should work).

David-Barrett-MS avatar Jun 11 '24 12:06 David-Barrett-MS