I have a script that retrieves Make, model, service tag, ip address and mac address for my dell hardware and puts it in a CSV file. It works but I have to handjam each computername for it to retrieve the info .
Current usage: c:\script>query.vbs computername username password
I would like to export all my computers out of AD and have the script parse that .txt file. I not sure how I make the script take the txt file as input. Code is below.
Any help would be greatly appreciated.
set args = Wscript.Arguments |
If args.Count <> 3 then |
Wscript.Echo "Usage: cscript query.vbs computer_name username password" |
Wscript.Quit 1 |
END IF |
strComputer = args(0) |
strUser = args(1) |
strPass = args(2) |
|
Set objFS = CreateObject("Scripting.FileSystemObject") |
Set objNewFile = objFS.openTextFile("output.csv",8,True) |
objNewFile.WriteLine "Host Name,Vendor,Model,Service Tag,IP Address,MAC Address" |
|
Set objLocator = CreateObject("WbemScripting.SwbemLocator") |
Set objSvc = objLocator.ConnectServer(strComputer, "root\cimv2", strUser, strPass) |
objNewFile.write strcomputer & "," |
|
|
Set colSWbemObjectSet = objSvc.InstancesOf("win32_computersystemproduct") |
For Each objSWbemObject In colSWbemObjectSet |
objNewFile.Write objSWbemObject.vendor & "," |
objNewFile.Write objSWbemObject.name & "," |
objNewFile.Write objSWbemObject.identifyingnumber & "," |
Next |
|
Set objWMIService = GetObject("winmgmts:" _ |
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") |
|
Set colAdapters = objWMIService.ExecQuery _ |
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") |
|
For Each objAdapter in colAdapters |
|
If Not IsNull(objAdapter.IPAddress) Then |
For i = 0 To UBound(objAdapter.IPAddress) |
objNewFile.Write objAdapter.IPAddress(i) & "," |
Next |
End if |
|
objNewFile.Write objAdapter.MACAddress & "," |
next |
|
objNewFile.WriteLine "" |