In this video we gone learn how to properly purge a solf deleted mailbox.
below there is the commands to be used to that:
How to purge a soft deleted mailbox in Office 365 – EXO Voice
1. We delete the user associated with the mailbox from the Office 365 Admin Center/Active Users interface (license must not be removed before deleting the user). At this point, the mailbox is soft deleted.
2. We then use PowerShell, to purge the user from Office 365:
– Get-MsolUser -ReturnDeletedUsers | fl UserPrincipalName,ObjectID
– Remove-MsolUser -ObjectID guid from previous command output -RemoveFromRecycleBin -Force
3. The mailbox will still be in soft deleted, and can be checked either in Exchange Admin Center/Recipients/Mailboxes/More/Deleted Mailboxes and in PowerShell with the command Get-Mailbox -SoftDeletedMailbox [email protected]
4. We should notice the fact that if we run Get-Mailbox -SoftDeletedMailbox [email protected]
| fl ExternalDirectoryObjectID, we no longer have a value on this parameter, as the MsolUser associated with this mailbox, has been previously purged, so basically the mailbox is now orphan.
How can we reconnect this mailbox to another user:
We can use the procedures mentioned in this article https://technet.microsoft.com/en-us/library/dn894100(v=exchg.150).aspx
What if I need to urgently purge the soft deleted mailbox:
1. Run this command in Powershell: New-Mailbox -InactiveMailbox address of soft deleted mailbox or guid -Name new unique name -MicrosoftOnlineServicesID a new unique UPN and then press enter in order to go ahead and provide a password for the new user mailbox that will get created. Do not attempt to use the parameter UserPrincipalName as you will receive an error message saying that you do not have permission to use it, stick with MicrosoftOnlineServicesID instead.
2. If all went well, we should see a yellow warning message that tells us to assign a license in 30 days.
3. Run Get-Mailbox -SoftDeletedMailbox to make sure the mailbox is no longer there.
4. After all this we can try again to purge the new mailbox:
– Soft delete the new user in Office 365 Admin Center
– Hard delete the MSOL User with Powershell (Remove-MsolUser -ObjectID guid -RemoveFromRecycleBin -Force)
– Check soft deleted mailboxes and purge it with Get-Mailbox -SoftDeletedMailbox new address | Remove-Mailbox -PermanentlyDelete
Beware of the difference between these commands:
– New-Mailbox -InactiveMailbox (used to reconnect mailboxes to other users than the initial account to which the mailbox was associated; the command will also remove the mailbox from a soft deleted state and will make it active)
– Undo-SoftDeletedMailbox (this is used to reconnect the soft deleted mailbox, if we still have the initial user to which the mailbox was previously associated, in the tenant; this command also removes the mailbox from a soft deleted state and will make it active)
– New-MailboxRestoreRequest (this command will be used if we want to restore the content of a soft deleted mailbox into a new active mailbox; the command will NOT remove the mailbox from its soft deleted state)
– We may also encounter this error message when trying to reconnect the mailbox: The parameters passed to the cmdlet represent a managed account, which doesn't match the namespace state, which is federated. – this means that we are trying to use a MicrosoftOnlineServicesID that has a federated domain (we should instead use the onmicrosoft.com domain)
– This entire procedure can be used similarly for soft deleted Public Folder Mailboxes that need to be purged:
Get-Mailbox -PublicFolder -SoftDeletedMailbox name of the PF Mailbox | Remove-Mailbox -PublicFolder -PermanentlyDelete
If we have any soft deleted mailboxes on Litigation Hold or In-Place Hold, these must be removed in order to purge them:
Get-Mailbox -InactiveMailboxOnly | fl Identity,LitigationHoldEnabled,InPlaceHolds
Get-Mailbox -SoftDeletedMailbox | fl Identity,LitigationHoldEnabled,InPlaceHolds
Set-Mailbox -InactiveMailbox [email protected]
see more in: https://aka.ms/o365supportcorner