Change DNS entry with Powershell

luca 03/09/2012 0

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, "")

Leave A Response »

This website uses cookies to ensure you get the best experience on our website maggiori informazioni

Questo sito utilizza i cookie per fonire la migliore esperienza di navigazione possibile. Continuando a utilizzare questo sito senza modificare le impostazioni dei cookie o clicchi su "Accetta" permetti al loro utilizzo.