Search Asset Info. in a Lan
On Error Resume Next
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile("c:\MyScript\inventory.csv")
a.WriteLine"Host Name,Serial Number,Brand,Model,Ram,HD,CPU,NIC Brand,NIC MAC,OS,Service Pack,Installed Date"
set objTextFile = fso.OpenTextFile("c:\MyScript\servers.txt",ForReading)
Do While NOt objTextFile.AtEndOfStream
StrComputer = objTextFile.ReadLine
Computer = strComputer
Wscript.Echo"Checking Computer: "&strComputer
Set objWMIService = GetObject("Winmgmts:{impersonationLevel=impersonate}!\\"&StrComputer&"\root\cimv2")
set colObjBios= objWMIService.ExecQuery _
("Select * from Win32_Bios")
For Each objBios in colObjBios
Computer = strComputer&","&ObjBios.SerialNumber&","&objBios.Manufacturer
Next
Others()
Sub Others
set colComputerSys= objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each ComputerSys in colComputerSys
Computer = Computer&","&ComputerSys.Model&","&ComputerSys.TotalPhysicalMemory
Next
set colDiskDrive= objWMIService.ExecQuery _
("Select Size from Win32_DiskDrive")
DiskCount = 0
For Each DiskDrive in colDiskDrive
Computer = Computer &","& DiskDrive.Size
DiskCount = DiskCount + 1
If DiskCount > 1 then Computer = Computer&crlf&"/"&DiskDrive.Size
Next
set colProcessor= objWMIService.ExecQuery _
("Select Name from Win32_Processor")
For Each Processor in colProcessor
Computer = Computer &","& Processor.Name
Next
set colNetwork= objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapter where DeviceID = 1 ")
For Each Network in colNetwork
Computer = Computer &","& Network.Name &","& Network.MacAddress
Next
set colobjOperatingSys= objWMIService.ExecQuery _
("Select Caption,ServicePackMajorversion,InstallDate from Win32_OperatingSystem")
'Wscript.Echo"Break Point Test"
For each objOperatingSys in colObjOperatingSys
strInstallDate = ObjOperatingSys.InstallDate
Computer = Computer &","&objOperatingSys.Caption&","&objOperatingSys.ServicePackMajorversion&","& WMIDateStringToDate(strInstallDate)
Next
a.WriteLine Computer
'Wscript.Echo Computer
Computer = Null
Loop
End Sub
Function WMIDateStringToDate(dtmInstallDate)
WMIDateStringToDate = CDate(Mid(dtmInstallDate, 5, 2) & "/" & _
Mid(dtmInstallDate, 7, 2) & "/" & Left(dtmInstallDate, 4) _
& " " & Mid (dtmInstallDate, 9, 2) & ":" & _
Mid(dtmInstallDate, 11, 2) & ":" & Mid(dtmInstallDate, _
13, 2))
End Function
a.close