Premkumar Yogeswaran's Blog

Active Directory | PowerShell | DNS | DHCP | Exchange Server | VM Ware

Bulk Adding Entries in DNS

Posted by Premkumar Yogeswaran on September 4, 2013

The format of the dnscmd.exe tool to add a record in DNS is:

dnscmd <server> /RecordAdd <zone> <node> <RR type> <RR data>

To create a host (A) record, the actual command would look like this:

dnscmd . /RecordAdd host1 A

The “.” syntax here refers to the local server; this can be easily substituted with an IP address or hostname of a remote DNS server.

Using some of the same techniques as before, combining dsncmd.exe with the “for” batch command allows us to do something like this:

for /f "tokens=1,2" %1 in (newhosts.txt) do
@dnscmd /RecordAdd %1 A %2

This assumes that the “newhosts.txt” file contains something like this:


Here’s a small twist, though: What if your list isn’t space delimited, but comma delimited? No problem, just adjust your command accordingly:

for /f "tokens=1,2 delims=," %1 in (newhosts.txt) do
@dnscmd /RecordAdd %1 A %2

The “delims=,” parameter tells the “for” command to use a comma as the delimiter, allowing us to use comma-separated input.

With this command, we now can pretty easily add large numbers of hosts to a DNS zone file.


Leave a Reply

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

You are commenting using your 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

%d bloggers like this: