Add DNS A Records via PowerShell

The following article is a summary to add host name (A) records in DNS via PowerShell.

Windows 2008

For DNS servers hosted on Windows 2008, use this script to add A records.

The script requires a CSV file with the host names and IP addresses that are planned to be added. The CSV file must contain a header row with Name and IP.  To add A records

  • Open an elevated PowerShell console from one of the servers hosting DNS
  • Run .\DNSHostRecordsPTR.ps1 to add the info from the CSV file as A records to DNS.

Windows 2012

In my opinion, adding A records is simpler in Windows 2012 or newer because you have a little more control of some of the settings.

Open an elevated PowerShell console from one of the servers hosting DNS. The following command can be used to add new A records. The bold, red text is user input based on A record information to add.

Add-DnsServerResourceRecordA -Name "HOSTNAME" -ZoneName "DNSZoneName.local" -AllowUpdateAny -IPv4Address "X.X.X.X" -TimeToLive 01:00:00

Good luck.

Reference(s):

Advertisements

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