Most companies now want to preserve all the data from an former employee, due to company standards or are required to hold the data for legal requirements. Office 365 provides a way to do this and not have to pay for the license. The simple process is that you want to place a hold on the mailbox (In-Place Hold or Litigation Hold) and then remove the license from the user. After that the mailbox data will be preserved.
I will cover the basic process below, if you need more details you can reference the Microsoft KB below.
IMPORTANT – Make sure the mailbox hold is applied before you remove the license.
Set Litigation Hold on the mailbox
- Set-Mailbox <User or Email Address> -LitigationHoldEnabled $true
Verify litigation hold on the mailbox
- Get-Mailbox <User or Email Address> | Format-List Name,LitigationHold*
Remove the Office 365 User Account
Depending on how your users are setup in Office 365, will dictate on how the accounts will be deleted. If you have cloud based accounts then you can simply select the user in Office 365 and remove the account. If you are using synchronized accounts from your local AD, then you will need to remove the account from local AD and then let the changes synchronize to Azure AD.