0

I have current Windows DNS server which is hosting something around 500 standard (non-AD) zones. I need transfer all of them to the new server. I copied .dns files from C:\Windows\System32\DNS from current to new server. However, they didn't appear. I googled and found that I need to use dnscmd command to add zones from files. Syntax for one zone is very clear for me, it should be

dnscmd nsserver /zoneadd domain.com /primary /file C:\Windows\System32\DNS\domain.com.dns

However, what should I do to add 500 files? Thank you in advance.

Senator14
  • 87
  • 1
  • 9

1 Answers1

0

Considering that you have the command you want to execute for your 500 files figured out, you can do this by just applying basic automation (no Windows DNS specifics required).

A simple FOR loop in CMD seems like the obvious approach for the DNSCMD /zoneadd command you provided, eg something like:

FOR %f IN (C:\Windows\System32\DNS\*.dns) DO dnscmd nsserver /zoneadd %~nf /primary /file %f

(provided you simply want to do this for all the matching files in that directory)


Alternatively you could take a more modern approach using Powershell instead. The Add-DnsServerPrimaryZone cmdlet appears to provide the equivalent functionality of your DNSCMD command.

Håkan Lindqvist
  • 35,011
  • 5
  • 69
  • 94
  • Hello and thank you for the reply. I'm trying to run your command but have this: C:\Windows\system32>dnscmd localhost /zoneadd domain .com /primary /file C:\Windows\System32\DNS\domain.c om.dns Command failed: DNS_ERROR_FILE_WRITEBACK_FAILED 9654 0x25B6 – Senator14 Aug 04 '16 at 18:42