Active Directory Metadata Cleanup

Metadata cleanup is the process which removes the failed Domain Controller’s object from Active Directory.

Metadata cleanup is required when you try to remove a domain controller from your Active Directory domain by using Dcpromo.exe and fail, or when you began to promote a member server to be a Domain Controller and failed, or you cannot demote the domain controller gracefully or DC has been failed /crashed due to hardware failure.

When you are performing any mentioned step above, you will be left with remains of the DCs object in the Active Directory. As part of a successful demotion process, the DCPROMO wizard removes the configuration data for the domain controller from Active Directory, but as noted above, a failed DCPROMO attempt might leave these objects in place.

The effects of leaving such remains inside the Active Directory may vary, but one thing is sure, whenever you’ll try to re-install the server with the same computer name and try to promote it to become a Domain Controller, you will fail because the DCPROMO process will still find the old object and therefore will refuse to re-create the objects for the new-old server.

In the event that the NTDS Settings object is not removed correctly you can use the Ntdsutil.exe utility to manually remove the NTDS Settings object this process is called metadata cleanup.

As a part of metadata you need to perform below procedures:
Perform metadata cleanup.
Manually remove the failed DC object from the site & Services.
Manually remove the computer object from the domain controller container in ADUC.
Manually remove the failed DC entries (NS, A, PTR, Etc records) from DNS console.

Note:  At least one healthy DC is required from where you can perform metadata cleanup.

Perform Metadata Cleanup steps using below articles:
Clean Up Server Metadata Windows Server 2003 and Windows Server 2003 R2

Clean Up Server Metadata Windows Server 2008 and higher