Update DNS IP Address from CSV

I made a script to update DNS records from a CSV. There are a couple of other topics that touch the issue on this forum…


The second one had some posts with some errors that I was seeing with my script, but I was able to suss out what I was doing wrong from the second comments from “Don Jones”. Anyway, I figured out I needed to look up the IP in the CSV in a strange way, for reasons I don’t quite understand. With CSV headers of “Computer,IP”.


Import-Module DNSServer
$zoneName = “DNS.zone”
$DNSServer = “dnsserver.dns.zone”
Import-CSV C:\dns\Records.csv | %{
$new = Get-DnsServerResourceRecord -ComputerName $DNSServer -ZoneName $zoneName -Name $.“Computer”
$old = Get-DnsServerResourceRecord -ComputerName $DNSServer -ZoneName $zoneName -Name $
Set-DnsServerResourceRecord -NewInputObject $new -OldInputObject $old -ComputerName $DNSServer -ZoneName $zoneName

Having to use ($($_.“IP”)) to get the IP from the CSV resolved the errors and made everything work as expected. Hope this helps someone else.