|
-
Dec 29th, 2005, 12:03 PM
#1
Thread Starter
New Member
Script DNS
Howdy all,
I need a script that will read all entries from the forward lookup zone and create the associated PTR reverse lookup records.
Can this be done?
Thanks!
OK here is the answer:
It reads a text file called om.txt in the same folder. The text file needs to be formated computername,ipaddress no spaces.
If you need the DNS provider here are instructions on how to install it:
http://msdn.microsoft.com/library/de.../installing_th
e_provider.asp
You will also need to change the domain name to your domain name.
VB Code:
on error resume next
Dim objDNS, objRR, objDNSServer
' ------ SCRIPT CONFIGURATION ------
strForwardDomain = "xerox.local"
dnsServer = "bplpcsmnps1.xerox.local"
strComputer = "."
Set objDNS = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftDNS")
set objRR = objDNS.Get("MicrosoftDNS_ResourceRecord")
set objDNSServer = objDNS.Get("MicrosoftDNS_Server.Name="".""")
' ------ END CONFIGURATION ---------
Const ForReading = 1
strCurrentDir = Left(WScript.ScriptFullName,InstrRev(WScript.ScriptFullName,"\"))
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("om.txt", ForReading)
strServers = objTextFile.ReadAll
objTextFile.Close
arrComputers = Split(strServers, vbCrLf)
for each strComputer in arrComputers
arrPTRInfo = Split(strComputer, ",")
strHostName = arrPTRInfo(0)
arrrevIP = Split(arrPTRInfo(1), ".")
strReverseRRAdd = arrRevIP (3) & "." & arrrevIP(2) & "." & arrRevIP(1) & "." & arrRevIP(0) & ".in-addr.arpa IN PTR " & strHostName & "." & strForwardDomain
strReverseDomain = arrrevIP(2) & "." & arrRevIP(1) & "." & arrRevIP(0) & ".in-addr.arpa"
strNull = objRR.CreateInstanceFromTextRepresentation( _
objDNSServer.Name, _
strReverseDomain, _
strReverseRRAdd, _
objOutParam)
set objRR2 = objDNS.Get(objOutParam)
WScript.Echo "Created Record: " & objRR2.TextRepresentation
next
Would be nice if I could read the list of addresses from the forward zone but it is easy enough to create the text file.
Last edited by skione; Dec 30th, 2005 at 01:35 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|