SOLVED

Recreate a mailbox for an existing user?

Copper Contributor

Here's what I'd like to do:

  • A mail user is created an assigned a license at some point. The user may have been synchronized from on-prem or may have been created directly in Azure AD.
  • At a later point, I want to recreate the user's mailbox without deleting the user so the user can start with a fresh mailbox.

Here's what I've tried:

  • Remove the user's license, verify the mailbox cannot be located by Get-Mailbox, add back the license. Result: the user is reattached to the same mailbox. Obviously this sequence happens within the 30-day retention period.
  • Convert the mailbox to shared, remove the user's license, add back the license. Result: the user is reattached to the same mailbox, though it is still shared.
  • Attempt to use Disable-Mailbox -PermanentlyDisable. Result: failure because the user is licensed.
  • Remove the user's license and then attempt to run Disable-Mailbox -PermanentlyDisable. Result: failure because the mailbox cannot be found.

I'm starting to think what I want to do is simply not possible, but I thought I'd fish for some fresh ideas since I'm out of them. One thought I had was to purge the deleted mailbox before the 30-day retention period is up, but I don't see a way to get a handle to it. Attempt to use Get-Mailbox with -IncludeInactiveMailbox and -SoftDeletedMailbox haven't located the mailbox for me.

11 Replies

@chad512 

 

Hi, you should be able to achieve this by purging the Deleted Users folder as you have indicated.  To do this, connect to Powershell as follows;

 

Connect-MsolService

 

Get-MsolUser -MaxResults 60 -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force

 

When recreating and licensing the user, you will now have a nice blank mailbox.

My goal is to not recreate the user, though. I want the user object left as it is, but I want to recreate that user's mailbox.
Ah I get it. Only way I can see this working is if the user was synced from AD. Process would be:

1). Move the user in AD to an OU which is not synced.
2). Wait for/or force ad sync. The O365 user will be moved to deleted users folder.
3). Run the PowerShell to purge Deleted users
4). Move the AD user back to synced OU, run sync, and the user is recreated for you.
5). Assign licence. Good to go.

Maybe still not exactly what you want, but I think it is as good as you are going to get.

@PeterRising 

 

I'm afraid you may be right. That leaves me with a user whose other cloud content is removed, which is bad in my case.

@chad512 

 

Am curious to know the reason why a fresh mailbox is desirable? :smile:

@PeterRising 

 

It's often the case in migration scenarios that users are provisioned in the service before their mail is migrated, so they start using things like OneDrive and SharePoint long before the mail switch. Migration testing may push data into the service mailbox that we want to purge before the actual migration. Recreating the user would mean the user loses all of their accumulated non-mail data.

best response confirmed by chad512 (Copper Contributor)
Solution

@chad512 

 

OK, maybe a little fiddly and messy, but how about enabling the Online Archive for the mailboxes in this situation and then create a new Exchange Retention Policy In the Exchange Admin Center to move content to the archive which is older than 14 days (along the lines of the below).  Assign this new retention policy only to the users who's mailboxes you want to clear out.

 

Screenshot 2020-05-23 at 20.12.44.png 

Once the move to archive has completed, disable the Online Archive for that user (making sure that you don't re-enable it for at least 30 days or the content will return).  Then, make sure you assign the default retention policy back to that user.

 

You'd have to be very diligent about assigning this temporary policy.  It could just as easily get you into trouble if assigned incorrectly.   If you plan to give it a try, test it to the hilt first I would say.

 

I'll give it a shot. Thanks!
Thanks Peter, this saved me during a migration in which a users In-Place Archive filled up because of a misconfiguration with the retention policy and I was able to blow out the mailbox and restart the migration. You rock man! Thanks!

@chad512 

I know this is an older post but I faced the same challenge and came across this ExO command that will achieve the desired result. Unfortunately, have been subject to this in the past and executed a permanent deletion of the account, recreate to correct the issue and then restore the content. I am so glad to come across this! I hope it referenced here will help others too.

John

 

https://techcommunity.microsoft.com/t5/microsoft-365/recreate-a-mailbox-for-an-existing-user/m-p/141...

 

@John Caldera which ExO command?  You linked back to this same post.  Did you mean to send a different link?

1 best response

Accepted Solutions
best response confirmed by chad512 (Copper Contributor)
Solution

@chad512 

 

OK, maybe a little fiddly and messy, but how about enabling the Online Archive for the mailboxes in this situation and then create a new Exchange Retention Policy In the Exchange Admin Center to move content to the archive which is older than 14 days (along the lines of the below).  Assign this new retention policy only to the users who's mailboxes you want to clear out.

 

Screenshot 2020-05-23 at 20.12.44.png 

Once the move to archive has completed, disable the Online Archive for that user (making sure that you don't re-enable it for at least 30 days or the content will return).  Then, make sure you assign the default retention policy back to that user.

 

You'd have to be very diligent about assigning this temporary policy.  It could just as easily get you into trouble if assigned incorrectly.   If you plan to give it a try, test it to the hilt first I would say.

 

View solution in original post