Home » General » Adding name servers to multiple DNS zones with PowerShell

Adding name servers to multiple DNS zones with PowerShell

Add multiple DNS servers as name servers to multiple DNS zones all in once. So this is essentially adding NS resource records to a zone, but doing it for multiple zones all at once. So, here’s a quick one-liner that does the trick, obviously substitute in your DNS server and name server FQDNs in the correct places. If it fails for any reason it will continue on, but report the zone it failed on.

 

Get-DnsServerZone -ComputerName dnsserver.vmwareenterprise.com | where {$_.zonetype -eq “primary” -or $_.zonetype -eq “secondary”} | ForEach-Object {try {Add-DnsServerResourceRecord -ZoneName $_.zonename -ns -ComputerName dnsserver.domain.com -name $_.zonename -NameServer newdnsserver.vmeareenterprise.com -ea:stop} catch {“$_”}}

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website