我需要通过多台PC远程验证dns并且我已经创建了代码但输出仍然显示错误,因为我设置的dns顺序没有正确的顺序。但是我想要有效的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
答案 0 :(得分:0)
这种作品。以下是VBS https://www.microsoft.com/en-au/download/details.aspx?id=2764和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