David-Barrett-MS / PowerShell-EWS-Scripts

A collection of PowerShell scripts that use EWS to perform actions against Exchange mailboxes
MIT License
118 stars 13 forks source link

Merge-MailboxFolder - Online Archive EXO #20

Closed chrisTR22 closed 1 year ago

chrisTR22 commented 1 year ago

Is it possible to merge mails from the primary mailbox to the exchange online archive of the same user? If i select -TargetArchive, the script doesn't find the target message store. I think this parameter is only for the Outlook Archive folder?

David-Barrett-MS commented 1 year ago

If both the primary mailbox and the archive mailbox are in Exchange Online, items can be copied/moved between them. If the mailboxes are in different environments (e.g. the primary on-premises with a cloud archive), then this script can't move the items (it won't be able to locate the target as the EWS endpoint will be different for that mailbox).

chrisTR22 commented 1 year ago

Is it possible to prevent the contacts from being moved to the online archive? All elements are currently being moved and i can't exclude the contacts to move in online archive.

David-Barrett-MS commented 1 year ago

Use -ExcludeFolderList parameter to prevent folders being processed.

chrisTR22 commented 1 year ago

I tested -ExcludeFolderList @("\Contacts","\Aufgaben") but the folder Contacts and Aufgaben will continue to be moved

David-Barrett-MS commented 1 year ago

Excluded folder just matches the display name, so don't use a \ (paths are not supported).

chrisTR22 commented 1 year ago

-ExcludeFolderList @("\Inbox\2018","\Inbox\2019") is your example, so i thought i have to use a \

David-Barrett-MS commented 1 year ago

Interesting point. :) And I've just double-checked, it does support paths (not sure what I was looking at earlier). If it's not matching, enable -Verbose as you should then see some info about the check.

chrisTR22 commented 1 year ago

I tested: .\Merge-MailboxFolder.ps1 -SourceMailbox xy@z.com -TargetArchive -OnlyItemsSentReceivedBefore "01/01/2020" -ExcludeFolderList @("Aufgaben") -ProcessSubfolders -createTargetFolder -Office365 -OAuth -OAuthClientID "1234" -OAuthTenantID "5678" -OAuthSecretKey "91011" -Impersonate -WhatIf But the Folder Aufgaben will continue to be processed. The Log says: Moving from xy@z.com:\Oberste Ebene des Informationsspeichers\Aufgaben to xy@z.com:\Top of Information Store\Aufgaben [MoveItems]Building list of items to move [MoveItems]Search filters applied: 2 In another Folder there is an entry: [IsFolderExcluded]Folder is of type: 1 [IsFolderExcluded]Folder not identified as search folder Checking for exclusions: Aufgaben This entry is missing for the folder Aufgaben. Do you have any idea why? I cant't understand why "Checking for exclusions" is skipped for the folder which has to be excluded.

David-Barrett-MS commented 1 year ago

I think I can see why - your Top of Information store has been localised to Oberste Ebene des Informationsspeichers, so the comparison I use (which allows for top of information store) doesn't work. If you add -Debug parameter, the script will stop at the compare point and show what it is comparing (it will also stop at some other points).

I'll need to update the script to take localisation into account. I haven't seen Top of Information Store localised before.

David-Barrett-MS commented 1 year ago

This should be fixed in 1.2.6 which is now published.