Windows Scripting BLOG

Due to limited time working on this project this place is not intended to people who are new to scripting but much more for people who are already familiar with the VBS/WMI syntax.

Donnerstag, 17. Mai 2007

Computer Info enumeration script

On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TextFile = FSO.OpenTextFile(Wscript.Arguments(1), 2, True) TextFile.Write"OPERATING SYSTEM,USER,COMPUTERNAME,MODEL,IP"
TextFile.WriteLine
IN_FILE = Wscript.Arguments(0)
Const PRO_READ = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(IN_FILE, PRO_READ)
strComputers = objFile.ReadAllobjFile.Close
arrComputers = Split(strComputers, vbCrLf)
For Each strComputer In arr
Computerserr.clear

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)if err.number <> 0 thenTextFile.Write "not reachable: " & strComputer
else
For Each objItem in colItems
TextFile.Write "" & objItem.Caption & " " & objitem.CSDVersion
Next
end if
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
if err.number <> 0 then
TextFile.Write ",not reachable: " & strComputer & ",not reachable: " & strComputer & ",not reachable: " & strcomputer
else
For Each objItem in colItems
TextFile.Write "," & objItem.UserName
TextFile.Write "," & objItem.NameTextFile.Write "," & objitem.Model
Next
end if
Set colItems1 = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration",,48)
if err.number <> 0 thenTextFile.Write ",not reachable: " & strComputer & vbnewline
else
For Each wbemObject in colItems1
For T=LBOUND(wbemObject.IPAddress) _ to UBOUND(wbemObject.IPAddress)
TextFile.Write "," & wbemObject.IPAddress(T) & vbnewline
next
next
end if
next
WSCript.Echo "Enumeration completed" 'created by Julian Ruf

Keine Kommentare: