Clean up Domain Controller DNS Records with Powershell

Nabeel 26 Reputation points


I was going through this page:

However, it only mentions the zone What about the zone and reverse lookup zones? Don't we have to delete that too after a DC is forcefully removed? It is not in the script.

Windows DHCP
Windows DHCP
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.DHCP: Dynamic Host Configuration Protocol (DHCP). A communications protocol that lets network administrators manage centrally and automate the assignment of Internet Protocol (IP) addresses in an organization's network.
1,021 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,344 questions
0 comments No comments
{count} vote

7 answers

Sort by: Most helpful
  1. Rich Matheisen 44,541 Reputation points

    Treat them the same way you'd treat any A, AAAA, CNAME, etc. DNS records for any machine you remove from your organization.

    0 comments No comments

  2. Gloria Gu 3,891 Reputation points

    @Nabeel Hi,

    Thank you for posting in Q&A!

    Do you want to perform metadata cleanup on a domain controller? If you want to achieve this, I would suggest you to use the GUI tools. Procedures should be done in Active Directory Users and Computers, Active Directory Sites and Services& DNS Entries.
    Using this method, it wold be a thoroughly clean up of the remain metadata of the old DC including DNS record.

    For more details, please refer to:

    Hope you have a nice day : )


    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. Nabeel 26 Reputation points

    @Rich Matheisen So it means yes we have to delete dns records from both zones: &

    In this case, how can we modify the powershell command to run for zone after running for zone

  4. Nabeel 26 Reputation points

    @Gloria Gu Hi,

    So it means if I use Active Directory Users and Computers to delete the DC as per, then all DNS records of the DC will be automatically removed also? No need to manually clean/remove DNS records of this DC?

  5. Nabeel 26 Reputation points

    @Gloria Gu

    The microsoft link mentions:

    When you use Remote Server Administration Tools (RSAT) or the Active Directory Users and Computers console (Dsa.msc) that is included with Windows Server to delete a domain controller computer account from the Domain Controllers organizational unit (OU), the cleanup of server metadata is performed automatically. Before Windows Server 2008, you had to perform a separate metadata cleanup procedure.

    You can also use the Active Directory Sites and Services console (Dssite.msc) to delete a domain controller's computer account, which also completes metadata cleanup automatically. However, Active Directory Sites and Services removes the metadata automatically only when you first delete the NTDS Settings object below the computer account in Dssite.msc.

    So it means we can EITHER use Active Directory Sites and Services or Active Directory Sites and Services to delete metadata of dead DC? We don't have to use BOTH?