Change DNS entry with Powershell

by luca
0 comment

Today I needed to change – using a script – a type A entry in my DNS.

Using WMI, you can get MicrosoftDNS_AType class that represents an A record saved in a Microsoft DNS server. The  class has a Modify method you can use to change TTL value and IP address of that record.

First, you have to get using Powershell a MicrosoftDNS_AType object that represents the record you need to change:

$dnsEntry = Get-WmiObject -ComputerName myDNSServer
-Namespace "root\MicrosoftDNS" -Class "MicrosoftDNS_AType"
-Filter "OwnerName = ''"


  • ComputerName, name or IP address of your DNS server
  • OwnerName, A record (including domain suffix) to be changed

Now you can invoke Modify to change the IP address, keeping the original TTL value:

$modifiedDnsEntry = $dnsEntry.Modify($dnsEntry.TTL, "")

Related Posts

Leave a Comment

ten + 8 =