Restore data for a deleted office 365 user
We need to create a New user and assign it a Exchange online licenses and let the mailbox be provisioned. Once the Mailbox is created for the new user, proceed further.
Connect PowerShell to Exchange Online using below command:
- $LiveCred = Get-Credential
- $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic –AllowRedirection
- Import-PSSession $Session
Then checked the old (deleted) user in Soft Delete
- Get-Mailbox –SoftDeletedMailbox (check for the deleted user)
- Get-mailbox –SoftDeletedMailbox –Identity “Name of the mailbox” | fl *guid*
- Copy the GUID (not Exchange GUID) in a notepad (1)
- Get-mailbox –Identity “Email address of the new user” | fl *guid*
- Copy the GUID (2)
Following command will copy the old mailbox’s email to the new mailbox.
- New-MailboxRestoreRequest -SourceMailbox "GUID (1)" -TargetMailbox "GUID (2)" -TargetRootFolder "Old Mailbox" –AllowLegacyDNMismatch
If user had Archive enabled we restored the archive mailbox
Kindly ensure that you had enabled archive for the new mailbox.
We run the below commands to get the ArchiveGuid
Get-Mailbox -Identity user@domain.com -SoftDeletedMailbox |fl " ArchiveGuid"
Get-Mailbox -Identity user@domain.com |fl "ArchiveGuid"
- New-MailboxRestoreRequest -SourceMailbox "GUID (1)" -TargetMailbox "GUID (2)" -TargetRootFolder "Old Mailbox" –AllowLegacyDNMismatch
**The TargetRootFolder parameter specifies the top-level folder in which to restore data. If you don't specify this parameter, the command restores folders to the top of the folder structure in the target mailbox or archive. Content is merged under existing folders, and new folders are created if they don't already exist in the target folder structure This is a Optional Parameter.
What does the TargetRootFolder parameter do? As previously explained, you can use the TargetRootFolder parameter to specify a folder in the top of the folder structure (also called the root) in the target mailbox in which to restore the contents of the inactive mailbox. If you don't use this parameter, mailbox items from the inactive mailbox are merged into the corresponding default folders of the target mailbox, and custom folders are re-created in the root of the target mailbox. The following illustrations highlight these differences between not using and using the TargetRootFolder parameter.
Folder hierarchy in the target mailbox when the TargetRootFolder parameter isn't used
Folder hierarchy in the target mailbox when the TargetRootFolder parameter is used
Comments
Post a Comment