Cannot remove mailuser

Marek G 171 Reputation points
2024-12-06T13:24:00.13+00:00

hello,

we have a problem deleting a user in EXO. When listing a user using get-mailuser badaccount | Select * is listed the user. When you try to delete an account using remove-mailuser, the command returns the error

"Write-ErrorMessage : Ex4215D1|Microsoft.Exchange.Configuration.Tasks.ManagementObjectNotFoundException|Recipient "baduser_RELOCNF_7e04b752" couldn't be read from domain controll

er "PA4PR07A15DC003.EURPR07A015.PROD.OUTLOOK.COM". This may be due to replication delays. Switching out of Forest mode should allow this operation to complete successfully."

The user was synchronized with onpremise ad, however removed from replication and deleted from deleted users....

any idea how to delete users from EXO ?

Thank you

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,666 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Alex Zhang-MSFT 3,230 Reputation points Microsoft Vendor
    2024-12-09T02:24:55.7233333+00:00

    Hello, @Marek G,

    Welcome to the Microsoft Q&A platform!

    The error message suggests that the recipient "baduser_RELOCNF_7e04b752" couldn't be read from the domain controller due to potential replication delays. Here are a few steps you can try to resolve this issue:

    1.Switch Out of Forest Mode: As the error message suggests, you can try switching out of Forest mode by using the following cmdlet. This allows the command to access Active Directory objects that aren't currently available in the default scope.

    Remove-MailUser -Identity "baduser_RELOCNF_7e04b752" -IgnoreDefaultScope
    

    2.Check Replication Status and Force Synchronization: Ensure that the replication between your on-premises Active Directory and Azure AD is complete. You can use the cmdlet below to check the status of your synchronization and force a synchronization if necessary.

    Get-ADSyncScheduler
    
    Start-ADSyncSyncCycle -PolicyType Delta
    

    3.Soft Delete and Permanently Delete: As your description, if the user is still showing up, you might need to soft delete the user first and then permanently delete them. Use the next cmdlet to finish this.

    Get-MailUser -Identity "baduser_RELOCNF_7e04b752" -SoftDeletedMailUser | Remove-MailUser -PermanentlyDelete
    

    4.Check for Retention Policies: Retention policies or litigation holds can prevent deletion. Verify if any such policies are applied to the user and remove them if necessary.

    5.Perform deletion in EAC: If the above steps don't resolve the issue, go to the Exchange Admin Center to delete the target user instead. Follow the steps below.User's image

    For details, please refer to https://learn.microsoft.com/en-us/exchange/recipients-in-exchange-online/manage-mail-users#use-the-eac-to-remove-mail-users.

    These steps should help you troubleshoot and resolve the issue with deleting the user in EXO. Let me know if you need more detailed instructions on any of these steps!


    If the answer is helpful please click on ACCEPT ANSWER as it could help other members of the Microsoft Q&A community who have similar questions and are looking for solutions.

    Thank you for your support and understanding.

    Best Wishes,

    Alex Zhang


  2. Alex Zhang-MSFT 3,230 Reputation points Microsoft Vendor
    2024-12-18T01:11:19.4766667+00:00

    Hello, @Marek G

    Great to know that the issue has already been resolved and thanks for sharing the solution so that others experiencing the same thing can easily reference this!

    Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others(https://docs.microsoft.com/en-us/answers/support/accepted-answers#why-only-one-accepted-answer)", I'll repost your solution in case you'd like to "Accept (https://learn.microsoft.com/en-us/answers/support/accept-answer#accepted-answer-in-a-question-thread)" the answer).     


    Issue Symptom:

    The user is experiencing an issue deleting a user account in Exchange Online (EXO). When listing the user with get-mailuser badaccount | Select *, the user appears. However, attempting to delete the account with remove-mailuser returns an error indicating that the recipient couldn't be read from the domain controller due to possible replication delays, and suggests switching out of Forest mode. The user was synchronized with on-premises AD but has been removed from replication and deleted from deleted users.

    Resolution:

    The issue ended up opening a ticket on M$ with the user in cloud being modified by the M$ technical.


    Hope you can consider accepting the answer as it could help other members of the Microsoft Q&A community who have similar questions and are looking for solutions.

    Thank you for helping to improve Microsoft Q&A!

    Best Wishes,

    Alex Zhang


Your answer

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