Permanently Clear Previous Mailbox Info

Published Jan 17 2018 12:11 PM 125K Views

We are introducing a new parameter that can be called by using the Set-User cmdlet in Exchange Online PowerShell. The feature is focused for customers doing migration of on-premises mailboxes to the cloud and you will be able to use it within three weeks or so (Edit 1/19: we updated this due to slower than expected rollout): Customers who have Hybrid or on-premises environments with AAD Connect / Dir Sync may have faced the following scenario:

  1. User has a mailbox on-premises. Jon is represented as a Mail User in the cloud.
  2. You are synchronizing the on-premises directory to the cloud in preparation to migrate to Exchange Online.
  3. Due to issues with the on-premises sync or due to a configuration problem, the user does not get the ExchangeGUID synchronized from on-premises to the cloud.
  4. If the Exchange GUID is missing from the object in the cloud, assigning an Exchange license to will cause Exchange Online to give the user a mailbox, converting the object from a Mail User to a User Mailbox. (Adding the license is a step required for the migration of the mailbox from on-premises to the cloud.)
  5. The end result is the user that has 2 mailboxes: one on-premises and one in the cloud. This is not good. Mail flow issues will follow.

Those doing these types of migrations will know that the ExchangeGUID value is very important as it helps Exchange Online identify that the user has a mailbox on-premises, and if an Exchange license is assigned in the cloud, a new mailbox should not be created. The immediate fix for this situation is to remove the Exchange License from This will convert the cloud object for Jon back to a Mail User. Mail flow should be restored at this point. The problem now is that you have an “unclean” cloud object for Jon. This is because Exchange online keeps pointers that indicate that there used to be a mailbox in the cloud for this user:

PS C:\WINDOWS\system32> Get-User | Select name,*Recipient*
Name PreviousRecipientTypeDetails RecipientType RecipientTypeDetails
---- ---------------------------- ------------- --------------------
Jon UserMailbox MailUser MailUser

Re-assigning the license after that will always err on the side of caution and Exchange Online will try to re-connect the (duplicate, temporary) mailbox in the cloud (and mailboxes can be reconnected for 30 days). Therefore Jon’s account in the cloud can’t be licensed in preparation for migration. Up to now, one of the few options to fix this problem was to delete *only in the cloud* Jon’s object and re-sync it from on-premises. This would delete from the cloud – but from all workloads, not only Exchange. This is problematic because Jon could have his OneDrive or SharePoint data in the cloud only and deleting his account means that this will be deleted too. If the account is then re-created, Jon and the tenant admin would have to work to recover to his new account all the data he used to have in OneDrive or SharePoint just because Exchange data needed to be “cleaned up”. The new parameter in the user cmdlet will allow tenant admin to clean up Exchange Online Jon’s object without having to delete it. To clean the object, you can run the following command:

PS C:\> Set-User -PermanentlyClearPreviousMailboxInfo
Are you sure you want to perform this action?
Delete all existing information about user “"?. This operation will clear existing values from Previous home MDB and Previous Mailbox GUID of the user. After deletion, reconnecting to the previous mailbox that existed in the cloud will not be possible and any content it had will be unrecoverable PERMANENTLY. Do you want to continue?
Yes  Yes to All  No  No to All  [?] Help (default is "Y"): Y

Executing this leaves you with a clean object that can be re-licensed without causing the 2-mailbox problem. Now you can on-board Jon’s on-premises mailbox following the usual steps. An alternative – a call to support to do the clean-up for you - is also not needed. Remember, cleaning up the user means that the older associated disconnected (duplicate) cloud mailbox is not recoverable. If you want to keep it or be able to check it’s content, we recommend using Soft Deletion or Inactive Mailboxes to keep the mailbox.

Note: This command is expected to be executed when you have an on-premises mailbox and a mailbox in the cloud for the same object due to bad AAD Connect configuration, to clean the object that can be re-licensed. The procedure allows you get out of the dual mailbox state and enable you to re-try on-boarding the mailbox immediately.
If you execute this for a user whose mailbox is cloud only after delicensing the user (and intend to later re-license the same user and expect to have a new clean mailbox for the user) - then this will not happen immediately. To avoid potential loss of mailbox data due to unintended/mistaken execution of the command, we retain the mailbox data for 30 days so that you may recover it. If your intention is to clean-up cloud only mailbox then you may hard delete the user account to re-create a clean mailbox.

Mario Trigueros Solorio

Not applicable
I have been in this scenario where a directory sync misconfiguration allowed Exchange Online to provision mailboxes instead of mail users and I can confirm, it was pretty hard to recover from this situation. This new feature is definitely an improvement. Implementing the feature as a switch for Set-User does not feel very intuitive though, but I like the clear warning text that's presented before asking confirmation.
Not applicable
I could have used this in my last migration project! It would have made things a lot easier. Thanks for adding this new switch.
Not applicable
Welcome addition to the service. I run into this a fair amount with clients; this will save a ton of time/effort.
Not applicable
I'm currently in this scenario, but moreso because the guy before me, decided to create Exchange accounts in O365 prior to Azure AD Connect setup. I've had to script the clean up and yes, it's not good as you lose so much more than just the mailbox. This new command will be very useful, shame it's not out earlier, as I could have tested it, this week.

Thanks and nice work!

Not applicable
This is a welcome addition, but the mailbox that was provisioned prematurely might now have stuff in it. it would be great if there was a way to restore the content from the smaller mailbox and merge it with the larger, with minimal code. Also, I've found that many of the times mailboxes are provisioned prematurely are related to the wrong immudableID flowing in a linked mailbox scenario. In that case, we're still required to hard-delete the cloud user.

Honestly, a better fix would be to allow us to disconnect the SPO workloads from the aAD object. We have several tools with Exchange, but those guys don't seem to acknowledge the problem.

Occasional Visitor

I was hopeful that this was the answer to my problem, but I get "Command completed successfully, but no user settings were changed." Still can't sync due to "Target user already has a primary mailbox". Users have significant OneDrive and Sharepoint content, so account delete is not a great option. Any insight would be appreciated.

Senior Member

@tguarriello we are in exactly the same boat and get the same "no user settings were changed". Did you or anyone else ever resolve this satisfactorily to be able to keep the previous OneDrive etc. account data? Any help would be much appreciated. Thanks

Occasional Visitor

@tguarriello @TOPIT : Did either of you find a solution to this?


I have tried many ways to remove the users Exchange license, but it doesn't actually seem to do anything. All the cmdlets claim the licence is still there, yet the Admin panel says it is gone. I am unable to use PermanentlyClearPreviousMailboxInfo or even Disable-Mailbox.


Is there a delay between removing the license and the decommissioning workflow? Or should it be fairly immediate?


The only way I seem to be able to resolve this is to completely remove the MSOL user. Does anyone have any current info on this? Thanks.

Occasional Visitor



You need to remove the Exchange Online license, then in Exchange Online Powershell enter the cmdlet.


Set-User -PermanentlyClearPreviousMailboxInfo


Reassign Exchange Online license


@mmomyI have tried to remove Exchange Online licence, after that I ran the command:


Set-User -PermanentlyClearPreviousMailboxInfo

But still getting "WARNING: The command completed successfully but no settings of 'Jon' have been modified"


Is there a delay between removing the license and the decommissioning workflow? Or should it be fairly immediate?


Because - After i re-assigned the Exchange Online licence, the mailbox is still not visible in EAC.

When I try to set-user -PermanentlyClearPreviousMailboxInfo there is an error:


A parameter cannot be found that matches parameter name 'PermanentlyClearPreviousMailboxInfo'.
+ CategoryInfo : InvalidArgument: (:) [Set-User], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Set-User
+ PSComputerName :


Just using set-user gives a warning that no setting has been changed. When I use get-user I can see the user has an UserMailbox in PreviousRecipientTypeDetails.


How can I get rid of this old mailbox. The User is still On-Premises and everytime I try to setup outlook the user gets connected to the empty online mailbox :sad:


Found a solution... set-user with  -PermanentlyClearPreviousMailboxInfo works when using the Exchange Online PowerShell V2 module.

Occasional Contributor

This procedure does nothing for me:


  1. Remove the user's license.
  2. Run Get-Mailbox <user> until it returns an error indicating the mailbox doesn't exist. This is my proxy for knowing that the back-end replication has completed.
  3. Run Set-User -PermanentlyClearPreviousMailboxInfo. This completes with no errors or warnings.
  4. Add the user's license.
  5. Run Get-Mailbox <user> until it returns the mailbox object. As with Step 2, this is just a proxy.
  6. Log in as <user>. The mailbox is the same one I started with.

My expectation is that at Step 6, I log into a fresh mailbox. Is that expectation wrong?

New Contributor


i tried this for two days now. i create new users with on premise mailboxes and online mailboxes.
this cmd is not working, the user mailbox data is not cleared at all.


I read on several other sites, that i need to remove the Exchange Online (Plan 2) license.

I tried this in the Office 365 Admin center / Users / licenses and i tried this with powershell.


It seems, that it´s not possible to remove a assigned Exchange Online (Plan 2) without removing Offce 365 E3 license and loose all data...

can you verifiy ? 

Senior Member

I had this issue ... Tech support had no idea how to fix it.

I found this article and they even told me not to do it. As they couldn't give a reason I tried it with a "less important" account.


It was simple, easy and worked.


The steps from support were:

As the users which are having mailboxes both in cloud as well as in on premises was due to assigning the license to those users before syncing it to Exchange on premises and then after syncing the exchange on premises with cloud it resulted in soft match which in turn resulted in two mailboxes. The steps that should be done to avoid it are:

  • Remove the license of the users who have two mailboxes (both in cloud and in on prem)
  • Then move those users in non sync OU in Active directory
  • Then hard delete those users from the cloud
  • Then move the users back to syncing OU in Active directory and then run delta sync
  • This will remove the mailbox from the cloud

Happy to supply Case number off-line if you want it. @The_Exchange_Team 

Senior Member


If the mb is on-premises, it's still there.

Go here -

Select the user > then the mail tab

Should say something like:

This user's on-premises mailbox hasn't been migrated to ‎Exchange Online‎. The ‎Exchange Online‎ mailbox will be available after migration is completed


Removing the E3 license shouldn't remove data for 30 days (if your grace period is set correctly) ... You re-add the license after killing the mailbox.

Probably a good idea to backup OneDDrive and Sharepoint data first ... I did, but they weren't touched

New Contributor

Hi all,

great article has helped me out,


is there a way to pipe to a list of csv users to this ?

like   import-user C;/ cc.csv | set-user -PermanentlyClearPreviousMailboxInfo



New Contributor

The command worked really fine, I could do the mailbox migration of a test user.

But know I'm having the error 550 5.1.10 RESOLVER.ADR.RecipientNotFound when I want to send an email to an on-premise user. I'do not know if may be there is an issue because this situation that originally there are mailboxes in both places, on-premise and cloud. 


I think important to mention the impacts of In-Place Hold. You must first remove any holds before complete this procedure. I found that if you have a mailbox hold the mailbox will not be soft deleted and the Set-User -PermanentlyClearPreviousMailboxInfo CMDlet will fail with "A parameter cannot be found that matches parameter name 'PermanentlyClearPreviousMailboxInfo'"which is not so intuitive. 


Procedure as I see it: 

  1. Backup data in mailbox! if you need it...
  2. Remove all Hold's from the mailbox. Test by trying 
    1. Disable-Mailbox <> -PermanentlyDisable 
    2. In EXO this will provide you with the Inplace policy GUID and blackarts will guide you from there ;)  (See links below) 
  3. Check DelayHoldApplied
    1. Get-Mailbox <> |fl compl*,delay*,inplace*
      These values should be set to false if not Set-Mailbox -Identity <> -RemoveDelayHoldApplied 
  4. Remove the user's license.
  5. Run Get-User RecipientType should -eq MailUser not Usermailbox
  6. Run Set-User -PermanentlyClearPreviousMailboxInfo. 
  7. Add the user's license.

If your at this point... Good luck! 



Other helps: 

Occasional Visitor

Hint for all: You have to remove also the Teams Exploratory license.


Occasional Visitor

I'd like to add that there is a bit of a delay between unassigning the Exchange Online license and the mailbox being deactivated.  You may need to wait a while for the user to no longer appear in the Exchange Online management page (or run get-mailbox against the user to see if the mailbox still exists in an active state). 


This delay ended up being why I was receiving the "no changes were made" message after running the set-user commandlet with the tag PermanentlyClearPreviousMailboxInfo.  After waiting a while for the mailbox to disappear from Exchange Online, the command worked. 

Version history
Last update:
‎Jul 16 2021 08:08 AM
Updated by: