Create multiple DNS A Records with PowerShell

Imagine you have to create hundreds or thousands of DNS records. Do you want to do that one by one? Surely not. I will show you an example how to create Beamer01 – Beamer100 and assign an IP address at the same time. Let’s jump in.

The Objective

Let’s say we want to create A Records Beamer01 – Beamer100 with the IP-Addresses –

The Code

Here is the example code you can build on. The script creates Beamer01 – Beamer99 with the corresponding IP addresses.

$ip = 1..99

foreach ($i in $ip) {

If ($i -lt 10) {

Add-DnsServerResourceRecord `
-ZoneName 'test.local' `
-Name Beamer0$i -IPv4Address 192.168.1.$i -A -Verbose

Add-DnsServerResourceRecord `
-ZoneName 'test.local' `
-Name Beamer$i -IPv4Address 192.168.1.$i -A -Verbose

I hope this was helpful.

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 )

Facebook photo

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

Connecting to %s

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