PowerShell: Recover items using EWS (supports recovering to original folder)

A PowerShell script that uses EWS (requires the EWS Managed API) to recover deleted items (from retention by default, but can be pointed to Deleted Items or any other folder).  The script will restore an item to the folder from which it was deleted if that information is present.

5 Star
1,570 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook
  • Can't Restore to LastActiveParentID
    2 Posts | Last post October 22, 2019
    • Hi David, I'm trying to use this script to restore items in an Archive Mailbox's Recoverable Items Folder that were put there by a retention policy. It seems that the lastActiveParentID restore is failing, because the value in the lastActiveParentID isn't matching to any of the folders enumerated. As a result, we error out without ever getting a value for lastActiveFolderId. Any thoughts?
    • If the lastActiveParentID is not found, then it implies that a folder has been deleted or maybe recreated.  If a folder is deleted then recreated, it will get a new Id, and any previous references to the deleted folder will be invalid.  The only other thing that springs to mind is that if you are recovering from the archive mailbox, the script may well just search for the restore folders in that mailbox - are the folders in the main mailbox?  This isn't something that occurred to me when I wrote the script, so I will take a look when I get a chance (though this most likely won't be for a week or two).
  • FAILED to bind to folder ArchiveMsgFolderRoot
    2 Posts | Last post November 28, 2018
    • Hi,
      I get this error but have used EWS Editor to successfully connect and view items. Any thoughts?
    • Enable verbose first of all; if the actual EWS error isn't shown there, then take an EWS trace to determine the actual error.  It could be that X-AnchorMailbox needs to be set, as I need to go through most of my scripts to check that (the advice has changed, and that header should be set for all EWS requests sent to EXO).