Restore deleted Office 365 mailbox via PowerShell

The Problem

So you’ve deleted an Office 365 user and need to get them back. Restore deleted Office 365 mailbox via PowerShell

The Fix

First off, you need to connect to Office 365 via PowerShell. You can find the instructions on how to do that here.

After you’ve done that, you simply need to run the following:

Undo-SoftDeletedMailbox user@domain.com -WindowsLiveID user@domain.com -Password (ConvertTo-SecureString -String ‘!!P@55w0rd!!’ -AsPlainText -Force)

The above will restore the mailbox user@domain.com and reset their password to !!P@55w0rd!!. Once restored, you will need to assign the account a license. Give it some time and you should see the mailbox come back.

*Note, do not be alarmed if it says that it’s ‘setting up a mailbox’. It’s not necessarily setting up a new mailbox.