DNS bulk host (A) records creation


Sometimes we need to create many DNS records in a short time. Using DNS Management console is not very convenient and fast method because you need to create each records separately by hand. I will show you how to do that using simple scripts based on:

  • Windows DNScmd command
  • Using DNSShell module for Windows PowerShell (really great module)
  • Using native DNS cmd-lets in PowerShell 3.0

Windows DNScmd command is by default available on Windows Server 2008/2008R2 server where DNS role has been installed. To use it on Windows Server 2003, you need to install Support Tools from server’s CD#1

DNSShell module needs to be downloaded separately from Chris blog who is REAL genius in DNS topic. His module for PowerShell is really great and very helpful.

Windows PowerShell 3.0 DNS cmd-lets are available in Windows 8 and Windows Server 2012 and are new feature added by Microsoft to manage DNS server.

PowerShell 3.0 can be also installed on Windows 7/2008/2008R2 for more information about that, please check my another article “Windows Management Framework 3.0 for Windows Server 2008/2008R2”


Before we start preparing script for bulk DNS records creation, let’s see how DNScmd syntax looks for single host (A) record. After that we would know which parameters should be inserted into input file for the script.

Note! To get help for DNScmd command you need to specify /? after its name or after any switch you want to get information

Now, we will prepare proper syntax to add single host (A) record into DNS zone. For that we need to know:

  • DNS server name
  • DNS zone name
  • host name
  • IP address

proper syntax to create host (A) record is:

dnscmd ServerName /RecordAdd DNSZoneName HostName RecordType IPAddress

Below you can find an example syntax

dnscmd %LOGONSERVER% /RecordAdd testenv.local test01 A

DNScmd command execution

instead of %LOGONSERVER% system variable, you can use DNS server name (if all  your DCs are DNS servers too, you can sinply use %LOGONSERVER%, in other case, you need to type DNS server name manually)

As you can see in DNS Management console, new record has been created

DNS record verification

We have complete syntax and now, we can create a script to create many DNS records in short time. First of all, we need an input file containing all required data. To create that file we need put in a flat text file 2 values:

  • host name
  • IP address

An example input file for script


and save this as i.e. newHosts.txt on C-Drive

Now, you can use below script to create many DNS records

for /f "tokens=1-2" %i in (c:newHosts.txt) do dnscmd %LOGONSERVER% /RecordAdd testenv.local %i A %j

Bulk DNS host records created

and you can verify that in DNS Management console

DNS records verification

DNSShell module for PowerShell

As I mentioned at the beginning of this article, this is separate module which needs to be downloaded. You can simply download it from


When you download it, you have to extract content into one of the following locations:

  • %HOMEPATH%DocumentsWindowsPowerShellModules
  • %WINDIR%SYSTEM32WindowsPowerShellv1.0Modules

PowerShell modules path

and import this module before the first use

Import-Module DNSShell

to list all available cmd-lets use

help *DNS*

Importing DNSShell module and list all available cmd-lets

From now, you have all cmd-lets available. Let’s start to create single host record in DNS using New-DNSRecord cmd-let

To be able to create host (A) record using DNSShell, you need:

  • DNS zone name
  • host name
  • IP address

You will find general syntax below

New-DNSRecord -Name HostName -RecordType A -ZoneName DNSZoneName -IPAddress IPAddress

and short example

New-DNSRecord -Name test01 -RecordType A -ZoneName testenv.local -IPAddress

New-DNSRecord example

and you can see command’s result in DNS Manager

DNS record veryfying

So, now we can create a script to automatically create many DNS records. As for PowerShell is better to use CSV file format instead of flat text file, I would suggest to prepare an example here. CSV file requires a header for each attribute, we need only 2 attributes to accomplish that


Save this file as newHosts.csv on C-Drive and use below script to create DNS records

Import-Module DNSShell
Import-CSV c:newHosts.csv | %{
New-DNSRecord -Name $_."HostName" -RecordType A -ZoneName testenv.local -IPAddress $_."IPAddr"

PowerShell script

and verify results in DNS Manager

DNS records veryfying

Native DNS cmd-lets in PowerShell 3.0

This is new feature and can be only used with PowerShell 3.0 which is available in Windows 8 and Windows Server 2012. There are variety of DNS cmd-lets to manage DNS server and one of  them is Add-DNSServerResourceRecordA and we will use it in this article.

Add-DNSServerResourceRecordA cmd-let

To create host record using this cmd-let we need to have prepared:

  • DNS zone name
  • host name
  • IP address

And now for a practice, we will create single DNS record using Add-DNSServerResourceRecordA

Add-DNSServerResourceRecordA -ZoneName DNSZoneName -Name HostName -IPv4Address IPAddress

according to above general syntax, let’s create host record

Add-DNSServerResourceRecordA -ZoneName testenv.local -Name test01 -IPv4Address

PowerShell 3.0 DNS record creation

and as in previous methods, just verify  if DNS record was created

DNS record verification

So, now the last part. We need to prepare script for multiple records creation. As we would need to use CSV file as in previous method (DNSShell module for Windows PowerShell), we will reuse it. An example CSV file is below


and save this as newHosts.csv file on C-Drive. When you do that, use below code for host (A) records creation

Import-CSV c:newHosts.csv | %{
 Add-DNSServerResourceRecordA -ZoneName testenv.local -Name $_."HostName" -IPv4Address $_."IPAddress"

Script output

and DNS Manager view to prove that record were created

DNS Manager and newly created DNS records

This time, that’s all!

Next part >>>

Author: Krzysztof Pytko


10 responses to “DNS bulk host (A) records creation”

  1. stjohnson says :

    Great DNS Tip and explanation. Hit the spot! Thanks so much!

  2. Ron says :

    Thank you for this detailed write up! You just saved me an hour or more of entering A and PTR records!

  3. Gautham says :

    Awesome Post!!

  4. Cividan says :

    Great article, really helpfull.

  5. aatif kungle says :

    Awesome Post,Very Helpful.

  6. Dave says :

    Thanks so much for making a tedious task very simple and fast for me. I am not good at scripts and the little bit that I learned on this made my life much simpler. Thanks for taking the time to post this.

  7. Rahul says :

    Awesome, this is exactly what I was looking for. Thanks!


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.