How to delete and restore Microsoft 365 users

This article also appears in my podcast and Youtube channel.

Case

You need to delete or restore one or more Microsoft 365 users. This article provides step by step guidance on how to delete and restore Microsoft 365 users from the Admin Center portal and from the Powershell msonline module.

Solution

Option 1: Via the Microsoft 365 admin center

To delete a user from a Microsoft 365 tenant via the Admin Center portal, go through the following steps.

  • Navigate with your Web browser to https,admin,dot,microsoft,dot,com.
  • On the left pane, click on “Users”, then click “Active Users”.
  • Under the “Active Users” section on the main area, tick the check boxes next to all users which you would like to delete and click “Delete Users”.
  • The deleted users are kept for 30 days in the deleted users container. If you need to restore any of the users within this 30-day period, navigate to the “Deleted users” section, tick the checkbox next to the user you wish to restore and click “Restore User”. You can restore only one user at a time from the admin center portal.
  • Please note that there is no option to permanently delete a user account from the Microsoft 365 Admin Center portal.

Option 2: Via the MSOnline Powershell module

To delete a user from a Microsoft 365 via the MSOnline Powershell module, go through the following steps:

  • In an elevated Powershell terminal, install and import the MSOnline and AzureAD Powershell modules. Bear in mind that the Microsoft Graph PowerShell SDK is the replacement for the Azure AD PowerShell module and is recommended for interacting with Azure AD. The Microsoft Graph API includes, in addition to Azure AD, APIs from other Microsoft services like SharePoint, Exchange, Outlook, etc, all accessed through a single endpoint with a single access token. Azure AD Graph PowerShell is based on Azure AD Graph which is deprecated.
  • Run the following commands in an elevated Powershell terminal.
Connect-MsOlService
Get-msoluser
#Return all deleted users
Get-MsolUser -ReturnDeletedUsers
#Restore an individual user
Restore-Msoluser -UserPrincipalName [UPN]
#Permanently remove a deleted user from the recycle bin
Get-MsolUser -ReturnDeletedUsers -UserPrincipalName [UPN] | Remove-MsolUser -RemoveFromRecycleBin -Force

Was this article helpful?

Related Articles