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

correct syntax to "unarchive" everything back to the primary mailbox? (Exchange Online/365) #11

Closed luckman212 closed 1 year ago

luckman212 commented 2 years ago

Hi @David-Barrett-MS and thank you for the excellent-looking script! 🙏

I am trying to wrap my head around the syntax and am a bit afraid to execute a command that might mangle someone's mailbox, so I'm hoping you can advise:

I want to move "everything" (all folders + subfolders) with the exception of system folders such as "Conversation Action Settings", "Top of Information Store", Recoverable Items" etc. back to the user's primary mailbox. Once it's done I intend to disable the Archive for him. I understand this will destroy the data in the archive after 30 days, so I want to be sure I move everything.

It seems the closest example would be your Example 5. But I think that will only take "Inbox" and "Sent Items". Is there a variant I can use to grab any & all other arbitrarily-named folders he may have in his archive? I put a note on issue #6 but that seems incorrect too.

Thank you kindly.

David-Barrett-MS commented 1 year ago

Sorry I didn't comment on this earlier. Example 5 is the closest. You could use WellKnownFolderName.MsgFolderRoot = WellKnownFolderName.ArchiveMsgFolderRoot if you want to copy the whole of the folder tree. That won't get system folders (they reside outside of MsgFolderRoot), though it will capture things like Top of Information store (which is MsgFolderRoot).