|
Question : Update DNS
|
|
Dear Experts, I am looking for a software/script that will allow me to update OR delete and then Add host records in my DNS servers (Windows 2000/2003). I have two DNS servers in the main office and I have one DNS server in my DR site. when switching to the DR site I have no way to update the DNS records to point to the DR site servers and sites which on different sub net in the domain. So I am looking for a solution that I can run as soon as I switch and the software/script will update all the records that I need. Thank you in advance, Roy
|
Answer : Update DNS
|
|
Hi Roy,
Sorry for the delay, didn't quite get a chance to finish up.
This version reads from a file in the format you've got above. You'll need to tell the script the file name by changing Const FILE_NAME = "" near the beginning of the script.
You must include training dots on the Hostnames within the file or it will fail to match them up to the zone.
Otherwise, copy the below into a text file and save as .vbs, then it will run either from the command line or by double clicking. If it creates any errors please let me know and we'll work through them.
' DNS Server Details
Const DNS_SERVER = "ServerName" Const DOMAIN_NAME = "yourdomain.com." ' Trailing . must be included
' Authentication Details
Const AUTH_USER = "UserName" Const AUTH_PASSWORD = "AccountPassword" Const AUTH_DOMAIN = "YourNetBIOSDomain"
' Filename containing changes
CONST FILE_NAME = "Hosts.csv"
' ' Main Code '
Set objNodes = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(FILE_NAME, 1)
Do While Not objFile.AtEndOfStream strLine = objFile.ReadLine arrLine = Split(strLine, ",") If UBound(arrLine) > 0 Then objNodes.Add arrLine(0), arrLine(1) End If Loop
Set objFile = Nothing Set objFSO = Nothing
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") Set objWMIService = objSWbemLocator.ConnectServer(DNS_SERVER, _ "root\MicrosoftDNS", _ AUTH_USER, _ AUTH_PASSWORD, _ "MS_409", _ "ntlmdomain:" & AUTH_DOMAIN)
Set colItems = objWMIService.ExecQuery("SELECT * FROM MicrosoftDNS_AType WHERE DomainName='" & DOMAIN_NAME & "'",,48)
For Each objItem in colItems If objNodes.Exists(LCase(objItem.OwnerName)) Then objItem.Modify "", objNodes(LCase(objItem.OwnerName)) End If Next
Set objNodes = Nothing
Set colItems = Nothing Set objWMIService = Nothing Set objSWbemLocator = Nothing
|
|
|
|