Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am migrating DNS zones (both forward and reverse) from Bind to Windows DNS. The reverse entries in the existing Bind server have not been maintained all that well for the static zones and I would rather not just import all the records.

I have however moved all the A records over to the Windows setup and made sure they are cleaned up. Now I have empty reverse zones.

What I am wondering is if there is a relatively easy way to tell the DNS server (Windows 2008 R2, Active Directory integrated), either via GUI or cmd line, to go ahead and create PTR records for all of the A records.

share|improve this question
    
If I can figure out how to get dnscmd to "uncheck" the "Update associated pointer (PTR) record" I could then do that in batch. If it can be re-checked via dnscmd it should add the PTR records for each A record I put in the batch file. I have all the zones setup. So right now when I edit an A record, unchecking the box, apply changes, re-check box, apply changes again, the appropriate PTR record gets created. –  J.Zimmerman Jul 24 '10 at 0:03
    
Can you share how you did that? –  LVLAaron Jan 7 '12 at 3:29

2 Answers 2

up vote 3 down vote accepted

How are your PowerShell skills? It could be a fairly straightforward matter of using

$hosts = Get-WmiObject -ComputerName $DomainController -Namespace 'root\MicrosoftDNS' -Class MicrosoftDNS_AType 

And then using the CreateInstanceFromPropertyData method:

foreach ($record in $hosts)  {
  $PTRRecord = [wmiclass]"\\$DomainController\root\MicrosoftDNS:MicrosoftDNS_PTRType
  $PTRRecord.createInstanceFromPropertydata("foo","bar","baz")
}

My example above is an excerpted (and sanitized) bit of a script I use to add CNAME records for existing A records. Doing PTRs should be quite similar; fix my foo-bar-baz handwave. There are more ideas and pointers in this Scripting Guys article.

share|improve this answer
    
Thanks! I am working out the details based on this and the scripting articles. If I can get something re-usable I will post back. –  J.Zimmerman Aug 5 '10 at 7:29

So a more complete answer follows. Note that it does very little error checking and is overly chatty. I grabbed most ideas from Scripting Guy and AndyN's answer. It's by no means perfect.

$server = "mydns.domain.name"

if (-not (Test-Connection -ComputerName $server)){Throw "DNS server not found"}

$srvr = $server -split "\."

$hosts = Get-WmiObject -ComputerName $server -Namespace 'root\MicrosoftDNS' -Class MicrosoftDNS_AType | where { $_.DomainName -eq "$($srvr[1]).$($srvr[2])" }

foreach ($record in $hosts)  {
  $resource = [WmiClass]"\\$($srvr[0])\root\MicrosoftDNS:MicrosoftDNS_ResourceRecord"
  $computer = $record.OwnerName
  $addr = $record.IPAddress -split "\."
  $rzone = "$($addr[1]).$($addr[0]).in-addr.arpa"
  $text = "$($addr[3]).$($addr[2]).$rzone IN PTR $computer"
write-host "$server, $rzone, $text"
  $resource.CreateInstanceFromTextRepresentation($server, $rzone, $text)
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.