I have a type mismatch in my VBScript script. I know that the value is correct, but not sure why it's coming up.
This is the line where the script terminates:
WScript.Echo "DNS Server Search Order: " & objNicItem.DNSServerSearchOrder
The script requires a file named servers.txt
(which has a list of servers in it, I am tesing using my own workstation name).
If I do an error on resume next
the script works. However if the servers list is populated. it displays the same information as the fisrt which works again for each host, so it's not correct.
'Input from the command line
If Wscript.Arguments.Count = 0 Then
Wscript.Echo "Usage: DNSAudit.vbs servers.txt "
Wscript.Quit
End If
'Input from txt file
Const ForReading = 1
Set objArgs = WScript.Arguments
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(ObjArgs(0), ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
StrNextLine = objTextFile.ReadLine
objDictionary.Add i, StrNextLine
i = i + 1
Loop
For Each objItem In objDictionary
Computer = objDictionary.Item(objItem)
'For Each Computer In Wscript.Arguments
'remote connection to another computer other than using variables
'Set ObjWMIService = GetObject("Winmgmts://COMPUTERNAME") for remote connection
Set ObjWMIService = GetObject("Winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2")
'If Err.Number <> 0 Then
'WScript.Echo "**************************************************************" & vbCrLf
'WScript.Echo "Connection Errors" & vbCrLf
'WScript.Echo Computer & " " & Err.Description
'WScript.Echo Computer & " " & Err.Description & " investigation required!"
'WScript.Echo "**************************************************************" & vbCrLf
''*********************************************************************************************************
'End if
WScript.Echo "**************************************************************" & vbCrLf
WScript.Echo "Starting Audit on " & computer
WScript.Echo "**************************************************************" & vbCrLf
WScript.Echo "**************************************************************" & vbCrLf
wscript.echo "List DHCP, DNS, WINS Adapter Parameters"
wscript.Echo "**************************************************************" & vbCrLf
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration")
For Each objNicItem in colItems
Wscript.Echo "DHCP Enabled: " & objNicItem.DHCPEnabled
Wscript.Echo "DHCP Lease Expires: " & objNicItem.DHCPLeaseExpires
Wscript.Echo "DHCP Lease Obtained: " & objNicItem.DHCPLeaseObtained
Wscript.Echo "DHCP Server: " & objNicItem.DHCPServer
Wscript.Echo "DNS Domain: " & objNicItem.DNSDomain
Wscript.Echo "DNS Domain Suffix Search Order: " & _
objNicItem.DNSDomainSuffixSearchOrder
Wscript.Echo "DNS Enabled For WINS Resolution: " & _
objNicItem.DNSEnabledForWINSResolution
Wscript.Echo "DNS Host Name: " & objNicItem.DNSHostName
WScript.Echo "DNS Server Search Order: " & objNicItem.DNSServerSearchOrder
WScript.Echo "Domain DNS Registration Enabled: " & objNicItem.DomainDNSRegistrationEnabled
Wscript.Echo "Full DNS Registration Enabled: " & _
objNicItem.FullDNSRegistrationEnabled
Wscript.Echo "IP Address: " & objNicItem.IPAddress
Wscript.Echo "MAC Address: " & objNicItem.MACAddress
Wscript.Echo "TCP Maximum Data Retransmissions: " & _
objNicItem.TcpMaxDataRetransmissions
Wscript.Echo "TCP NumC onnections: " & objNicItem.TcpNumConnections
Wscript.Echo "WINS Host Lookup File: " & objNicItem.WINSHostLookupFile
Wscript.Echo "WINS Primary Server: " & objNicItem.WINSPrimaryServer
Wscript.Echo "WINS Secondary Server: " & objNicItem.WINSSecondaryServer & vbCrLf
Wscript.Echo "Adaptor: " & objNicItem.Description & vbCrLf
Next
Next