In an Active Directory environment, we will look at how to remove and clean up a Domain Controller (DC) server using Metadata Cleanup commands. But under what circumstances should you perform a Metadata Cleanup?
If an Additional Domain Controller in your organization encounters a hardware or software failure and you need to remove its Additional DC role, you may no longer be able to access the affected server. In such cases, Metadata Cleanup can be performed from another available Domain Controller to remove the failed DC’s metadata from Active Directory.
In the Active Directory Users and Computers console, under the Domain Controllers Organizational Unit (OU), you will see the servers that are configured as Domain Controllers, including your Additional Domain Controllers.
Note: Before removing a Domain Controller from the existing environment using Metadata Cleanup, make sure that the DC is completely offline and will never be brought back online. Do not perform Metadata Cleanup if the Domain Controller may be restored or reconnected to the network.
Let’s Start Metadata Cleanup

On the Primary Domain Controller (PDC) server, open Command Prompt with Run as administrator privileges.
The commands we will use are listed below. You can also follow the process using the screenshots provided.
Ntdsutil
Ntdsutil: Metadata Cleanup
Metadata Cleanup: Connections
Server Connections: Connect to server HQDC1
Server Connections: Quit
Metadata Cleanup: Select Operation Target
Select Operation Target: List Sites
Select Operation Target: Select Site 6
(Select the site where the Domain Controller to be removed is located.)
Select Operation Target: List Domains
Select Operation Target: Select Domain 0
(Select the appropriate domain. In this example, 0 is selected because there is only one domain in the environment.)
Select Operation Target: List Server in Site
Select Operation Target: Select Server 0
(Select the Domain Controller for which Metadata Cleanup will be performed.)
Select Operation Target: QuitCode language: PHP (php)

Metadata Cleanup: Remove Selected ServerInformation about the selected Domain Controller will be displayed. Verify that the correct DC is selected, and confirm the operation if the information is correct.

After completing these steps, the Domain Controller role and its associated metadata have been removed from the existing Active Directory environment.
Post-Procedure Tasks Metadata Cleanup
After performing the Metadata Cleanup operation, verify that the corresponding Domain Controller object has been removed from the relevant site under Active Directory Sites and Services.

The Domain Controllers that were removed through the Metadata Cleanup process must also be removed from the Name Server (NS) records in both the Forward Lookup Zones and Reverse Lookup Zones.

This document provides the step-by-step procedures for performing Metadata Cleanup in an Active Directory environment. The objective is to ensure that the Metadata Cleanup process is completed thoroughly and in accordance with standard Active Directory practices.
The purpose of this procedure is to remove the Domain Controller role from an Active Directory environment when the Domain Controller is offline or has become permanently unavailable.
Important: Do not perform Metadata Cleanup until you have confirmed that the Domain Controller being removed is completely powered off and will not be brought back online. Performing Metadata Cleanup while the Domain Controller is still active or may reconnect to the environment can lead to Active Directory replication and structural issues.
Read more: How to Fix Outlook Search Not Updating in Shared Mailboxes
More learn metada cleanup: https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/deploy/ad-ds-metadata-cleanup






