Announcement

Collapse
No announcement yet.

DNS Suffix Search Order

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • DNS Suffix Search Order

    Can someone help me write a simple vbscript pull the DNS Suffix Search Order from multiple servers using a file (e.g. servers.txt) and output file to my server with the following extension (i.e. txt, csv or xls)

    'So far here's what I have, see below. But this script reports the 'DNSSearchOrder and Not the DNSSuffixSearchOrder. Can someone help.

    Const ForWriting = 2

    arrComputers = Array("Server1, Server2")

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objReport = objFSO.CreateTextFile("dnsreport.csv", ForWriting)

    objReport.WriteLine "Server Name,IP Address,Preferred DNS,Alternate DNS"

    For Each strComputer in arrComputers
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

    For Each objNetCard in colNetCards
    For Each objAddress in objNetCard.IPAddress
    strIP = objAddress
    Next
    On Error Resume Next
    strDNSServerSearchOrder = Join(objNetCard.DNSServerSearchOrder, ",")
    Next

    objReport.WriteLine strComputer & "," & strIP & "," & strDNSServerSearchOrder
    Next

    objReport.Close

  • #2
    Re: DNS Suffix Search Order

    I found this with a little help from my friend google: (Modified to fit you existing code)

    Let me know if this works for you or not and I'll see what else I can find.

    *NOTE* The array needs to have each item in quotes ("Item1","Item2","Item3",etc)

    Code:
     
    Const ForWriting = 2 
    On Error Resume Next 
    
    arrComputers = Array("Sever1", "Server2") 
    
    Set objFSO = CreateObject("Scripting.FileSystemObject") 
    Set objReport = objFSO.CreateTextFile("dnsreport.csv", ForWriting) 
    
    objReport.WriteLine "Server Name,IP Address,Preferred DNS,Alternate DNS" 
    
    For Each strComputer in arrComputers 
      Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")  
      Set colNetCards = objWMIService.ExecQuery _ 
      ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") 
      For Each objNetCard in colNetCards 
        For Each objAddress in objNetCard.IPAddress 
          strIP = objAddress 
        Next 
      Next 
    
      For Each objNicConfig In colNetCards
        If Not IsNull(objNicConfig.DNSDomainSuffixSearchOrder) Then
           For Each strDNSSuffix In objNicConfig.DNSDomainSuffixSearchOrder
             strDNSServerSearchOrder = Join(strDNSSuffix, ",") 
           Next
        End If
      Next
      objReport.WriteLine strComputer & "," & strIP & "," & strDNSServerSearchOrder 
    
    Next 
    
    objReport.Close
    TechNet Link: http://technet.microsoft.com/en-us/l.../ee692588.aspx
    Hobie
    Last edited by Hobie; 20th April 2011, 03:11. Reason: Fixed the method call

    Comment


    • #3
      Re: DNS Suffix Search Order

      Hi Hobie,
      First of all thank you for helping out.

      The script didn't work. It gave me the servernames and ip only and the other information (i.e. DNS Suffix Search List Order) was not included on the output file. Maybe it's the order that is in?

      Comment

      Working...
      X