Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Azure and Microsoft 365 / How to Restore Deleted Users in Entra ID (Microsoft 365)

March 17, 2024 Azure and Microsoft 365PowerShell

How to Restore Deleted Users in Entra ID (Microsoft 365)

When you delete a user account in Azure (Microsoft 365), the user is not deleted immediately. The disabled user account is stored in AAD for 30 days. In this article, we’ll look at how to restore a deleted user in Azure AD (AAD) using Azure Portal or PowerShell.

In Azure AD, there are two modes for deleting objects (users):

  • Soft delete – a user is deleted from the active tenant users and the user account is suspended (moved to the AAD recycle bin). At the same time, all user attributes (including M365 group membership, assigned access permissions to Exchange Online mailboxes and folders, calendar permissions, Teams chats, etc.) remain unchanged. Azure services will automatically delete such an account after 30 days;
  • Hard delete (permanent) – an object is deleted from the Azure Recycle Bin and cannot be restored using the built-in tools (you may force delete any object from Azure AD without waiting 30 days).

To delete or restore users, a Global administrator or User administrator role must be assigned to your account.

The easiest way to restore a deleted user in AAD is to use the Azure Portal:

  1. You can find a list of deleted users available to restore in the Azure AD admin center (https://aad.portal.azure.com/);
  2. Go to Users and select Deleted Users. There is a list of deleted users that includes the date when the user was deleted (Deletion date) and the date when the user will be permanently removed from AAD (Permanent deletion date);
  3. Find a user you want to restore (you can search a user by the User principal name or add other user attributes as filters), select it, and click Restore user; Restore deleted users in Azure AD Portal
    Note that when you delete a user, the user’s userPrincipalName attributes change. If earlier it was [email protected], for example, after you delete the user the object ID in AAD is added to the beginning: [email protected]
  4. Confirm the restore action. You will see the message: User successfully restored;
  5. When you restore a deleted user, the Entra ID/Microsoft 365 group membership and the set of assigned AAD licenses are fully restored as well.
The previous article describes how to restore deleted objects in on-premises Active Directory.

Also, you can restore a user in AAD/Microsoft 365 using PowerShell. To do it, you must use the MSOnline and AzureAD Powershell modules or Microsoft Graph API.

You can display a list of all deleted users (with the full list of attributes) using this command:

Get-MsolUser -ReturnDeletedUsers | fl *

You can display specific user properties only (name, ID, user creation or deletion date):

Get-MsolUser -ReturnDeletedUsers | select DisplayName, ObjectId,SoftDeletionTimestamp, WhenCreated

Get-MsolUser -ReturnDeletedUsers - list deleted users with powershell

You can restore a user by their ObjectID:

Restore-AzureADMSDeletedDirectoryObject -Id 98813128-ffb1-4c55-b11f-6c58d7d66

Restore-AzureADMSDeletedDirectoryObject

You can also restore a user by a UPN using the Restore-MsolUser cmdlet:

Restore-MsolUser -UserPrincipalName "[email protected]"

  • In the previous command, you may use an optional parameter –AutoReconcileProxyConflicts, which allows you to assign a new proxy address to a user if the old one is busy
  • or you can set a new UPN immediately using the option -NewUserPrincipalName "[email protected]"

Restore-MsolUser - restore deleted Microsoft 365 users

To permanently delete a user from AAD, the following command is used:

Remove-MsolUser –userprincipalname [email protected] -RemoveFromRecycleBin

You can also use the Azure AD audit logs to search for user deletion events. For example, the following script will find a user deletion event (you will see who deleted a user and when), and return a UPN and ObjectID of a deleted user:

Import-Module AzureADPreview -UseWindowsPowerShell

Use this command to load the module for the classic Windows PowerShell version into the PowerShell Core session.

Get-AzureADAuditDirectoryLogs  -Filter "category eq 'UserManagement' and OperationType eq 'Delete'" |where-object TargetResources -like ("*AlexTest*")|select-object -ExpandProperty TargetResources

Get-AzureADAuditDirectoryLogs - find Azure AD user deletion event

You can restore a user by their object ID using the Restore-AzureADMSDeletedDirectoryObject cmdlet.

0 comment
0
Facebook Twitter Google + Pinterest
previous post
Fix: Remote Desktop Services Is Currently Busy
next post
Sending an E-mail to a Microsoft Teams Channel

Related Reading

View Windows Update History with PowerShell (CMD)

April 30, 2025

Uninstalling Windows Updates via CMD/PowerShell

April 18, 2025

Allowing Ping (ICMP Echo) Responses in Windows Firewall

April 15, 2025

How to Pause (Delay) Update Installation on Windows...

April 11, 2025

How to Write Logs to the Windows Event...

March 3, 2025

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMware
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025
  • How to Write Logs to the Windows Event Viewer from PowerShell/CMD

    March 3, 2025
  • How to Hide (Block) a Specific Windows Update

    February 25, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Outlook Keeps Asking for Password on Windows
  • Checking User Sign-in Logs in Entra ID (Microsoft 365)
  • How to Manually Configure Exchange or Microsoft 365 Account in Outlook 365/2019/2016
  • Search and Delete Emails from User Mailboxes on Exchange Server (Microsoft 365) with PowerShell
  • Fix: Microsoft Outlook Search Not Working on Windows 10/11
  • Blank Sign-in Screen in Office 365 Apps (Outlook, Teams, etc.)
  • Removing Built-in Teams Chat in Windows 11
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top