Create Reverse DNS records

asked 2021-04-17T11:21:22.817+00:00
Rising Flight 2,566 Reputation points

Hi Experts

i have few servers which dont have reverse dns records.
for example. server1 and server2 have forward lookup records. i.e server1@Company portal .com pointing to, server2@Company portal .com pointing to
but these servers dont have reverse dns records.

  1. How do i create reverse DNS records for these servers using powershell.
  2. i have servers list in the below format, how do i import the csv file and create reverse dns records


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.
925 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.
4,616 questions
{count} votes

Accepted answer
  1. answered 2021-04-17T12:51:29.123+00:00
    Andreas Baumgarten 66,011 Reputation points Microsoft MVP

    Hi @ RisingFlight-7863 ,

    you can give this a try (not tested by myself). Use the script on your own risk.

    $file = "server.csv"
    Import-Csv -Path $file | foreach {
        $name = (($_.IPAddress).Split("."))[3]
        # Modify the -ZoneName to your needs (name of the reverse lookup zone in DNS)
        # Modify the PtrDomainName domain part to your needs (
        Add-DnsServerResourceRecordPtr -Name "$name" -ZoneName "" -AllowUpdateAny -TimeToLive 01:00:00 -AgeRecord -PtrDomainName "$"

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Andreas Baumgarten

    No comments

1 additional answer

Sort by: Most helpful
  1. answered 2021-05-10T21:45:13.767+00:00
    Rising Flight 2,566 Reputation points

    will the below script work for me


    $ServerName = "MyDomainController"   
    $domain = ""   
    Import-Csv C:\temp\Records.csv | ForEach-Object {   
    #Def variable   
    $Computer = "$($_.HostName).$domain"   
    $addr = $_.IP -split "\."   
    $rzone = "$($addr[1]).$($addr[0])"   
    #write-host $rzone  
    #Create Dns entries   
    dnscmd $Servername /recordadd $domain "$($_.HostName)" A "$($_.IPAddress)"   
    #Create New Reverse Zone if zone already exist, system return a normal error   
    #dnscmd $Servername /zoneadd $rzone /primary   
    #Create reverse DNS   
    dnscmd $Servername /recordadd $rzone "$($addr[3]).$($addr[2])" PTR $HostName