Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: DNS Host A Record Changes Modify Failover Entries Create modify Delete MicrosoftDNS \root\MicrosoftDNS MicrosoftDNS_AType WMI
Example of task to perform:
ServerA.Domain.com 1.1.1.1 TTL=20 Push Change for fail over ServerA.Domain.com 2.2.2.2 TTL=5 Push change to Fail back ServerA.Domain.com 1.1.1.1 TTL=20If it possible to change the TTL that would be a plus. If not just updating the record will do the job.Any ideas?
; Returns information about the host address (A) resource records on a DNS server. strComputer = "." objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" : strComputer : "\root\MicrosoftDNS") colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_AType") ForEach objItem In colItems data = "IP Address: " : objItem.IPAddress : @LF data = data : "Owner Name: " : objItem.OwnerName : @LF data = data : "Container Name: " : objItem.ContainerName : @LF data = data : "DNS Server Name: " : objItem.DnsServerName : @LF data = data : "Domain Name: " : objItem.DomainName : @LF data = data : "Record Class: " : objItem.RecordClass : @LF data = data : "Record Data: " : objItem.RecordData : @LF data = data : "Text Representation: " : objItem.TextRepresentation : @LF data = data : "Time-to-Live: " : objItem.TTL : @LF Pause( '\root\MicrosoftDNS', data ) NextHere is a link to the Modify method: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682181(v=vs.85).aspx
The code might look something like this:
; Modify the record ; ; Connect to the WMI Service strComputer = "." objWMIService = ObjectGet("winmgmts:{impersonationLevel=impersonate}!\\" : strComputer : "\root\MicrosoftDNS") ; Run a query to get the record we want to change colItems = objWMIService.ExecQuery("SELECT * FROM MicrosoftDNS_AType WHERE ContainerName='domain.example' AND OwnerName='test.domain.example'", , 48) ; Loop through the results ForEach objItem In colItems ; Modify the record ttl = objItem.TTL objItem.Modify( ttl, "1.2.3.4" ) Next ExitReference: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682123(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms682132(v=vs.85).aspx http://technet.microsoft.com/en-us/library/ee692588.aspx http://gallery.technet.microsoft.com/scriptcenter/e08cfb59-2a10-4582-bc2d-381bbba25f4f http://www.indented.co.uk/2008/10/23/modifying-dns-records-with-wmi/
Article ID: W18510
Filename: Modify DNS Entries .txt
File Created: 2014:06:24:08:39:44
Last Updated: 2014:06:24:08:39:44