搜索 DNS 顺序

search DNS order

我需要通过多台电脑远程验证 dns,我已经创建了代码,但输出仍然显示错误,因为我设置的 dns 顺序不正确 order.But 我想验证仅通过 dns 不检查命令的 dns。我是这个领域的初学者,希望你们能帮忙,非常感谢:-) 下面是代码

strCompName = "site A", "site B", "site C"

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" & strCompName & "\root\cimv2")
Set config = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

'this is fix dns that is set up to valid with old dns
New_dns = Array ("1.1.1.1",_
                  "2.2.2.2",_
                  "3.3.3.3)

For Each conf In config

        If Not IsNull(conf.DNSServerSearchOrder) Then
            For Each strDNSServer In conf.DNSServerSearchOrder

                ' in this code i want to valid the existing dns in pc with dns that is set up

                If strDNSServer = New_dns(number) Then
                    wscript.echo "CORRECT!     " + strDNSServer
                Else
                    wscript.echo "WRONG!       " + strDNSServer
                End If

            Next
        End If

Next

这类作品。这是 VBS https://www.microsoft.com/en-au/download/details.aspx?id=2764 and for WMI https://msdn.microsoft.com/en-us/library/windows/desktop/aa394217(v=vs.85).aspx.

的帮助

请注意,每台计算机有两个 DNS 服务器。

Dim Computers(2)
Computers(0) = "127.0.0.1"
Computers(1) = "127.0.0.1"
Computers(2) = "127.0.0.1"


For each strcomputer in Computers

    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\" & strcomputer & "\root\cimv2")
    Set config = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

    'this is fix dns that is set up to valid with old dns
    New_dns = Array ("1.1.1.1", "1.1.1.1",_
                      "2.2.2.2", "2.2.2.2",_
                      "192.168.1.1", "192.168.1.1")
    For Each conf In config

            If Not IsNull(conf.DNSServerSearchOrder) Then
                For Each strDNSServer In conf.DNSServerSearchOrder

                    ' in this code i want to valid the existing dns in pc with dns that is set up
    msgbox New_dns(number)
                    If strDNSServer = New_dns(number) Then
                        wscript.echo "CORRECT!     " + strDNSServer
                    Else
                        wscript.echo "WRONG!       " + strDNSServer
                    End If
            number=number+1
                Next
            End If

    Next
Next