Quick and easy bulk DNS record creation with Powershell (A and PTR)_

🇺🇦 Resources to help support the people of Ukraine. 🇺🇦
December 15, 2014 @16:08
This post has been restored from an archived copy. Links may have changed or be broken.

I found myself needing to make roughly 100 DNS records for a DHCP pool. In BIND I usually accomplish this with some fancy vi(1) work, but sadly this was for a Windows based lab at work.

Thanks to Powershell, it wasn't too difficult.

Powershell for DNS

Essentially you use ForEach to iterate over a range (i..j counts from i to j, i...j counts through by subtracting i from j or something silly like that) and then construct your DNS parameters from there.

Here is the script:

ForEach ($num in 50..149) {
dnscmd.exe /RecordAdd rochlab.com "dhcp-$num.rochlab.com;" /CreatePTR A 192.168.20.$num
}
Comment via e-mail. Subscribe via RSS.