troubleshooting Question

Remote script to read DNS settings

Avatar of rtmcmullen
rtmcmullen asked on
ProgrammingWindows BatchInstallation
6 Comments1 Solution887 ViewsLast Modified:
I have a script that reads a list of nodes from a text file and am having a little trouble in trying go insert logic to read DNS suffix settings etc., I am getting i variable not defined and think I'm overlapping loops.... here is the script:

Option Explicit
Dim oFSO, WSHShell, oTextStream, strComputer
Dim objWMIService, colProcessList, objItem, objAdapter

Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("")

Set oTextStream = oFSO.OpenTextFile("wslist.txt")'Open file containing computer names

Do Until oTextStream.AtEndOfStream
    strComputer = Trim(oTextStream.ReadLine)
    If (strComputer <> "") Then
        ' Trap possible error.
        On Error Resume Next
        Set objWMIService = GetObject("winmgmts:" _
            & "{impersonationLevel=impersonate}!\\" _
            & strComputer & "\root\cimv2")
        If (Err.Number <> 0) Then
            ' Error raised. Restore normal error handling.
            On Error GoTo 0
            Wscript.Echo "" & strComputer _
                & " not available or WMI not installed"
            ' No error. Restore normal error handling.
            On Error GoTo 0
            Set colProcessList = objWMIService.ExecQuery _
                ("Select * from Win32_NetworkAdapterConfiguration " _
                & "where IPEnabled = TRUE")
            For Each objItem In colProcessList

'READ DNS Settings
For Each objAdapter in colAdapters
   WScript.Echo "  DNS"
   WScript.Echo "  ---"
   WScript.Echo "    DNS servers in search order:"
   If Not IsNull(objAdapter.DNSServerSearchOrder) Then
      For i = 0 To UBound(objAdapter.DNSServerSearchOrder)
         WScript.Echo "      " & objAdapter.DNSServerSearchOrder(i)
   End If
   WScript.Echo "    DNS domain: " & objAdapter.DNSDomain
   If Not IsNull(objAdapter.DNSDomainSuffixSearchOrder) Then
      For i = 0 To UBound(objAdapter.DNSDomainSuffixSearchOrder)
         WScript.Echo "    DNS suffix search list: " & _
        End If
    End If


Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros