Let’s assume someone left the company, and you deleted its Office365 user account. As it turns out, this also deletes the attached mailbox. If you would like to attach this mailbox to someone else, i.e. to still be able to access vital company or customer data, here is how.
First, check to see whether the mailbox was “soft-deleted” and still can be recovered:
Get-Mailbox -SoftDeletedMailbox | Select-Object Name,ExchangeGUID
Each recoverable mailbox in this list has a unique GUID. To attach this mailbox to someone else, you need to also find out the GUID for the still active mailbox that you’d like to attach the deleted mailbox to:
$liveMailbox = Get-Mailbox existingPerson@somecompany.onmicrosoft.com | Select-Object Name,ExchangeGUID
Next, once you have both GUIDs, issue a request to attach the old mailbox data to the new mailbox, and specify a target root folder like “Old Mailbox Content”. This will be the mail folder under which the new mailbox shows up:
New-MailboxRestoreRequest -SourceMailbox [ENTER_GUID_OF_SOFTDELETED_MAILBOX] -TargetMailbox $liveMailbox.ExchangeGUID -AllowLegacyDNMismatch -TargetRootFolder "Old Mailbox Content"