Results 1 to 1 of 1

Thread: Script DNS

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    14

    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:
    1. on error resume next
    2. Dim objDNS, objRR, objDNSServer
    3. ' ------ SCRIPT CONFIGURATION ------
    4. strForwardDomain = "xerox.local"
    5. dnsServer = "bplpcsmnps1.xerox.local"
    6. strComputer = "."
    7. Set objDNS = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftDNS")
    8. set objRR = objDNS.Get("MicrosoftDNS_ResourceRecord")
    9. set objDNSServer = objDNS.Get("MicrosoftDNS_Server.Name="".""")
    10. ' ------ END CONFIGURATION ---------
    11.  
    12. Const ForReading = 1
    13.  
    14. strCurrentDir = Left(WScript.ScriptFullName,InstrRev(WScript.ScriptFullName,"\"))
    15.  
    16. Set objFSO = CreateObject("Scripting.FileSystemObject")
    17. Set objTextFile = objFSO.OpenTextFile _
    18. ("om.txt", ForReading)
    19.  
    20. strServers = objTextFile.ReadAll
    21. objTextFile.Close
    22.  
    23. arrComputers = Split(strServers, vbCrLf)
    24.  
    25. for each strComputer in arrComputers
    26. arrPTRInfo = Split(strComputer, ",")
    27.  
    28. strHostName = arrPTRInfo(0)
    29. arrrevIP = Split(arrPTRInfo(1), ".")
    30. strReverseRRAdd = arrRevIP (3) & "." & arrrevIP(2) & "." & arrRevIP(1) & "." & arrRevIP(0) & ".in-addr.arpa IN PTR " & strHostName & "." & strForwardDomain
    31. strReverseDomain = arrrevIP(2) & "." & arrRevIP(1) & "." & arrRevIP(0) & ".in-addr.arpa"
    32.  
    33. strNull = objRR.CreateInstanceFromTextRepresentation( _
    34. objDNSServer.Name, _
    35. strReverseDomain, _
    36. strReverseRRAdd, _
    37. objOutParam)
    38. set objRR2 = objDNS.Get(objOutParam)
    39. WScript.Echo "Created Record: " & objRR2.TextRepresentation
    40.  
    41. 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
  •  



Click Here to Expand Forum to Full Width