System Inventory script that outputs to Excel format (CSV)
Looking for a free software inventory solution?
This VBscript pulls HOST NAME, OS, Edition, SP, Vendor, Model, Service Tag, Total Memory, Number of Processors, PROCESSOR, PROCESSOR TYPE, HD0 Size,HD0 free space. It also outputs the data into a Excel spreadsheet.
1. Open notepad
2. Copy and paste below text to notepad
3. Save the file with .vbs extension.
4. To run the script, Example: cscript queryRemoteServers.vbs servername username password
5. Once you run the script, you will find the output data in output.csv of the script directory,
'------------ SCRIPT STARTS HERE--------------
'---------------------------------------------------------
'script to query remote computers
'for device inventory purposes
'---------------------------------------------------------
set args = Wscript.Arguments
If args.Count <> 3 then
Wscript.Echo "Usage: cscript queryRemoteServers.vbs server_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,OS,Edition,SP,Vendor,Model,Service Tag,Total Memory,Number of Processors, PROCESSOR,PROCESSOR TYPE,HD0 Size,HD0 freespace,HD1 Size,HD1 freespace"
Set objLocator = CreateObject("WbemScripting.SwbemLocator")
Set objSvc = objLocator.ConnectServer(strComputer, "root\cimv2", strUser, strPass)
objNewFile.write strcomputer & ","
Set colSWbemObjectSet = objSvc.InstancesOf("win32_operatingsystem")
For Each objSWbemObject In colSWbemObjectSet
objNewFile.Write objSWbemObject.caption & ","
objNewFile.Write objSWbemObject.csdversion & ","
Next
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 colSWbemObjectSet = objSvc.InstancesOf("Win32_computersystem")
For Each objSWbemObject In colSWbemObjectSet
objNewFile.Write objSWbemObject.totalphysicalmemory & ","
objNewFile.Write objSWbemObject.numberofprocessors & ","
Next
Set colSWbemObjectSet = objSvc.ExecQuery("select * from Win32_processor where deviceID='CPU0'")
For Each objSWbemObject In colSWbemObjectSet
objNewFile.Write objSWbemObject.Name & ","
objNewFile.Write objSWbemObject.caption & ","
Next
Set colSWbemObjectSet = objSvc.ExecQuery("select * from win32_logicaldisk where drivetype='3'")
For Each objSWbemObject In colSWbemObjectSet
objNewFile.Write objSWbemObject.size & ","
objNewFile.Write objSWbemObject.freespace & ","
Next
objNewFile.WriteLine ""