2

Is there a way or a tool that I can get a csv (or even tab delimited) list of all Forward Lookup Zone records and zones in a Windows 2008 R2 DNS Server?

The DNS Server is the built-in Windows one, and shows as version 6.1.7601.17514

I did notice Export-DnsServerZone but it looks like it's a per-domain basis

Kevin
  • 133
  • 1
  • 2
  • 14

1 Answers1

3

Powershell and WMI.

PS C:\>Get-WMIObject -Namespace 'Root\MicrosoftDNS' -List

That will list the many different classes in the MicrosoftDNS namespace.

Want to get all resource records on the server?

PS C:\>Get-WMIObject -Namespace 'Root\MicrosoftDNS' MicrosoftDNS_ResourceRecord

Want to get only the A records?

PS C:\>Get-WMIObject -Namespace 'Root\MicrosoftDNS' MicrosoftDNS_AType

Want to get only the AAAA records?

PS C:\>Get-WMIObject -Namespace 'Root\MicrosoftDNS' MicrosoftDNS_AAAAType

Want to export all the A records to a CSV?

PS C:\>Get-WMIObject -Namespace 'Root\MicrosoftDNS' MicrosoftDNS_AType | Select OwnerName,RecordData | Export-Csv C:\Users\me\desktop\dns.csv -NoTypeInformation

Want to use a tab delimiter instead of a comma? Add -Delimiter "``t" to Export-Csv. (Only one backtick in front of the t... Stackexchange markdown can't handle my skillz.)

Want to get all the domains on the DNS server that are forward lookup zones only, and not Root Hints?

PS C:\>Get-WmiObject -Namespace 'Root\MicrosoftDNS' MicrosoftDNS_Domain | ? { $_.ContainerName -Notlike '..RootHints' -And $_.ContainerName -NotLike '..Cache' -And !$_.Reverse } | Select Name
Ryan Ries
  • 55,481
  • 10
  • 142
  • 199
  • Keep getting an error when I try `Get-WMIObject -Namespace 'Root\MicrosoftDNS' MicrosoftDNS_ResourceRecord | Select OwnerName,RecordData | Export-Csv C:\Users\me\desktop\dns.csv -NoTypeInformation` stating `Invalid parameter` – Kevin Nov 21 '14 at 14:46
  • 1
    @Kevin So start backing up from the end of the statement and see for yourself which exact part is causing the error. – Ryan Ries Nov 21 '14 at 15:01
  • Doing that now... weird thing is, it dumps out a 3+M csv with over 4200 records (which seems right) – Kevin Nov 21 '14 at 15:13
  • Wow... it's the first part... `Get-WmiObject -Namespace 'Root\MicrosoftDNS' MicrosoftDNS_Domain` Here's a shot of the actual error http://prntscr.com/58mbek – Kevin Nov 21 '14 at 15:17
  • 1
    @Kevin You'll be happy once you update to Server 2012 and can use a simple [`Get-ServerDnsZone`](http://technet.microsoft.com/en-us/library/jj649861(v=wps.620).aspx). – jscott Nov 21 '14 at 16:06
  • Honestly, I can't stand Server 2012. Too much like Win 8 ;) – Kevin Nov 21 '14 at 16:30