Manage Windows DNS records with PowerShell
List DNS zones and records and change the address of an A record with the DnsServer module.
The DnsServer PowerShell module lets you query and change the records of a Windows DNS server without using the graphical console.
Prerequisites
Check that the module is available (it ships with the RSAT tools / the DNS role):
Get-Module DNSServer -ListAvailable
List zones and records
# Zones hosted by the server
Get-DnsServerZone -ComputerName dns01
# All records of a zone
Get-DnsServerResourceRecord -ComputerName dns01 -ZoneName example.com
# Filter by record type
Get-DnsServerResourceRecord -ComputerName dns01 -ZoneName example.com -RRType A
Get-DnsServerResourceRecord -ComputerName dns01 -ZoneName example.com -RRType CNAME
Change the address of an A record
Read the existing record, make a modified copy, then replace the old record with the new one:
$new = $old = Get-DnsServerResourceRecord -ComputerName dns01 -ZoneName example.com -Name app-dev
$new.RecordData.IPv4Address = [System.Net.IPAddress]::Parse('192.0.2.10')
Set-DnsServerResourceRecord -NewInputObject $new -OldInputObject $old -ZoneName example.com -ComputerName dns01
Repeat with another -Name for each record to change.