Export zone files from Windows 2008 R2 DNS

I had to export some zone files to move to a BIND DNS server from Windows 2008 R2. I found a couple scripts online but nothing worked. Finally I modified one of them and the resulting powershell script that worked for me is below.

$dnsserver = "[YOUR DNS SERVER NAME]"

$zones = dnscmd $dnsserver /enumzones

for ($i = 7; $i -lt ($zones.length -3); $i++) {
    $zonename = $zones[$i].substring(1)
    $zonename = $zonename.substring(0,$zonename.indexof(" "))
    $file = $zonename + ".txt"
    dnscmd $dnsserver /ZoneExport $zonename $file
}

Those zone files will end up in C:\Windows\System32\dns

(Original script here: http://myitpath.blogspot.com/2011/10/migrating-lot-of-zones-from-microsoft.html )

Hope this can help.

One thought on “Export zone files from Windows 2008 R2 DNS

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: