Someone recently contacted me if I can assist them in exporting the PTR records in csv format, they have already tried
DNSCMS /Exportzone or /enumrecords but getting the last octave of the ip address.
e.g.
for a zone 154.10.in-addr.arpa, they were getting
1.100 PTR zzzhostname
Which is supposed to be 10.154.100.1
So here we go again, Powershell will come to rescue, below script was written that just needs input as DNS server name & offcourse we need DNS module which can be downloaded from dnsshell.codeplex.com , I have pockaged it inside the script folder so we don’t have to worry.
Download & extract the zip file from below link:
https://github.com/VikasSukhija/Downloads
update the Varibale $dnserver = “DNSHostName” inside .ps1 powershell script.
Run the script to extract the records in the desired format.
########################################################### # Author: Vikas SUkhija (http://techwizard.cloud) # Date: 5/23/2016 # Modified: # Reviewer: # Decsription: Export reverse DNS records # Prereq: http://dnsshell.codeplex.com/ (already downloaded) ########################################################### $date1 = get-date -format d $date1 = $date1.ToString().Replace("/","-") $logs = ".\Logs" + "\" + "Processed_" + $date1 + "_.log" $csv = ".\" + "Revrecords_" + $date1 + "_.csv" Start-Transcript -Path $logs $collection = @() ##############Import DNS Module and extract report######### import-module .\DnsShell\DnsShell.psd1 $dnserver = "DNSHostName" ######update dns server Name $revzone = Get-DnsZone -Server $dnserver | ? {$_.ZoneName -like '*in-addr.arpa'} $exportrevdns = $revzone | Get-DnsRecord -RecordType PTR | Select Hostname,Name,TTL,RecordType,ZoneName $exportrevdns | foreach-object{ $Hostname = $_.Hostname $Name = $_.Name $TTL = $_.TTL $RecordType = $_.RecordType $ZoneName = $_.ZoneName $IP1 = $Name.split(".") $IP = $IP1[3] + "." + $IP1[2] + "." + $IP1[1] + "." + $IP1[0] $coll = "" | Select Hostname,IP,TTL,RecordType,ZoneName $coll.Hostname = $Hostname $coll.IP = $IP $coll.TTL = $TTL $coll.RecordType = $RecordType $coll.ZoneName = $ZoneName $collection += $coll } #################################################### $collection | export-csv $csv -notypeinfo stop-transcript #####################################################
Tech Wizard