how to delete from m365 azure an orphaned user ad account

Owen, Cameron 0 Reputation points
2026-01-16T23:18:09.1466667+00:00

an active directory domain controller failed and was forcibly removed. A new user account created on the problem DC had been synchronized via AzureADSync to M365 Azure / Entra, and is now orphaned, as the new AD account had never replicated to other domain controllers. It was necessary to create a new AD account for the user, but of course it does not synch to Azure. How do I delete the orphaned account from azure? A relevant posting indicates that remove-mguser can do this - I found that it was blocked.

Microsoft 365 and Office | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2026-01-16T23:18:19.4566667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To delete an orphaned user account in Microsoft Entra (formerly Azure AD) that was created through directory synchronization, you can use the Microsoft Graph PowerShell module. Here are the steps you should follow:

    1. Ensure you have the necessary modules installed: Make sure that the Microsoft Graph PowerShell module is installed.
    2. Connect to Microsoft Graph: You need to connect to your Microsoft 365 tenant using the appropriate permissions. Use the following command:
         Connect-MgGraph -Scopes User.Read.All, User.ReadWrite.All
      
    3. Identify the orphaned user: You can find the orphaned user by using the Get-MgUser cmdlet with a filter for the user's principal name or display name. For example:
         $user = Get-MgUser -Filter "userPrincipalName eq '******@contoso.com'"
      
    4. Remove the orphaned user: Once you have identified the user, you can remove them using the Remove-MgUser cmdlet:
         Remove-MgUser -UserId $user.id
      

    If you encounter any issues with permissions or if the command is blocked, ensure that you have the necessary permissions assigned to your account to delete users in Microsoft Entra.


    References:

    0 comments No comments

  2. Owen, Cameron 0 Reputation points
    2026-01-18T02:21:43.49+00:00

    Accepted - this is what I needed, solved my problem perfectly! It was the -scopes parameter of connect-mgGraph that I was missing.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.