Tom Powers
asked on
wmi VB Scripting
I created a vb script that pulls all Computers on network I need to see what computers are static and which ones are Dhcp I'm so close but Do While with a Loop is giving me fits. I just need this vb script to read entire list of computers and then for each one write computername and IPEnabled = True or IPEnabled =False. here is my vb script
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="c:\computersDHCP.txt"
Set objFile = objFSO.CreateTextFile(outFile,True)
Const ForReading = 1
Set objFSOR = CreateObject("Scripting.FileSystemObject")
Set objTextFileR = objFSOR.OpenTextFile _
("computers2.txt", ForReading)
Do Until objTextFileR.AtEndOfStream
strComputer = objTextFileR.Readline
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = 'True'")
For Each objItem in colItems
If objItem.DHCPEnabled = TRUE Then
objFile.Write strComputer & " DHCP enabled" & vbCrLf
objFile.Close
Else
objFile.Write strComputer & " DHCP enabled" & vbCrLf
End If
objTextFile.Close
Next
Computers2.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER