In order to recover an inactive mailbox in Office 365 (Exchange Online), you must search for the mailbox, get the Exchange GUID and then recover it to a new mailbox.
I will cover the basic process below, if you need more details, reference the Microsoft KB below.
List inactive mailboxes with Exchange GUID
- Get-Mailbox -InactiveMailboxOnly | Format-List Name,DistinguishedName,ExchangeGuid,PrimarySmtpAddress
Create InactiveMailbox variable
- $InactiveMailbox = Get-Mailbox -InactiveMailboxOnly -Identity <identity of inactive mailbox>
- Use the ExchangeGUID from the previous step as the indentity
Recover inactive mailbox to a new mailbox
- New-Mailbox -InactiveMailbox $InactiveMailbox.DistinguishedName -Name johndoe -FirstName John -LastName Doe -DisplayName “John Doe” -MicrosoftOnlineServicesID email@example.com -Password (ConvertTo-SecureString -String ‘P@ssw0rd’ -AsPlainText -Force) -ResetPasswordOnNextLogon $true
- The command above will create a new user and mailbox for John Doe and recover the inactive mailbox set in the variable above
- The MicrosoftOnlineServicesID must match the PrimarySMTPAddress returned from the first step
Configure the new user
- Make sure you assign a license to the newly created user
- If you are using AD Connect, make sure that the user on-premise shares the same anchor value as the synchronized user for soft matching to work correctly