When users leave the company you might want to retain the email for a longer period than the default 30 days. By enabling litigation hold you can retain mailboxes longer than 30 days, before you disable a user you can set the litigation hold to any value you would like. But at some point you might need the mailbox to be re-enabled for some reason. In this manual I am going to explain how to do it.
STEP 1: Open a new Power Shell window and type the following command
Next type in the following command to connect to Exchange Online, and login using the screen that pops up:
Connect-ExchangeOnline -UserPrincipalName <adminaccount emailaddress> -ShowProgress $true
STEP 2: Now lets get a list of all inactive mailboxes on your tenant. Run the following command to get a nice and clean list:
Get-Mailbox -InactiveMailboxOnly | FL Name,DistinguishedName,ExchangeGuid,PrimarySmtpAddress
STEP 3: From the result from step 2 we are going to need the PrimarySmtpAddress to get more properties. We are going to create a variable that contains the properties of the inactive mailbox.
$InactiveMailbox = Get-Mailbox -InactiveMailboxOnly -Identity <PrimarySmtpAddress>
STEP 4: The last step is to convert the inactive mailbox to a active mailbox with an active Office 365 user. So you will need to create a new mailbox identity where we will attach the inactive mailbox to. So make sure to fill in the following fields from the code below:
NOTE: If you have an on-premise environment with AD-Connect, you might need to use the .onmicrosoft.com address to reactivate the mailbox. The user/mailbox can be attached to a on-premise user afterwards.
Run the following command after changing the values, it might take up to a few minutes to complete.
New-Mailbox -InactiveMailbox $InactiveMailbox.DistinguishedName -Name "Cor den Boer" -FirstName Cor -LastName den Boer -DisplayName "Cor den Boer 2azure" -MicrosoftOnlineServicesID firstname.lastname@example.org -Password (ConvertTo-SecureString -String 'P@ssw0rd' -AsPlainText -Force) -ResetPasswordOnNextLogon $true
The result should look like this:
The user is now restored, and you should be able to logon with the credentials provided.