Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PC inventory

Status
Not open for further replies.

aegis70

MIS
Apr 1, 2004
2
US
I am trying to write script to gather computer info from our network to include computer name, serial number, OS & version, pc description, and ip address and input it to a text file. Anyone can help? Much appreciated

Aegis
 
I have this code so far. However how can I fix and combine the codes to write a single report, if possible in excel? Is it possible to scan a whole subnet and gererate a report consisting of computer name, serial number, computer description, and IP address? Thanks in advance

On Error Resume Next

' This is just for serial number
Dim System
if Wscript.Arguments.Count >0 then
sSystem=Wscript.Arguments(0)
end if
ComputerName = InputBox("Enter the name of the computer you wish to query")
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName &""
Set SNSet = GetObject( winmgmt1 ).InstancesOf ("Win32_BIOS")
for each SN in SNSet
MsgBox "The serial number for the specified computer is: " & SN.SerialNumber
Next

'This is a separate code
Set oShell = CreateObject("wscript.Shell")
Set env = oShell.environment("Process")
strComputer = env.Item("Computername")
Const HKEY_LOCAL_MACHINE = &H80000002
Const UnInstPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
".\root\default:StdRegProv")


report = " Computer Name: " & strComputer & vbCrLf & "******************************************" & vbCrLf & vbCrLf
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "OS Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objItem in colItems
report = report & "Caption: " & objItem.Caption & vbCrLf
report = report & "Description: " & objItem.Description & vbCrLf
report = report & "EncryptionLevel: " & objItem.EncryptionLevel & vbCrLf
report = report & "InstallDate: " & objItem.InstallDate & vbCrLf
report = report & "Manufacturer: " & objItem.Manufacturer & vbCrLf
report = report & "MaxNumberOfProcesses: " & objItem.MaxNumberOfProcesses & vbCrLf
report = report & "Name: " & objItem.Name & vbCrLf
report = report & "Organization: " & objItem.Organization & vbCrLf
report = report & "OSProductSuite: " & objItem.OSProductSuite & vbCrLf
report = report & "RegisteredUser: " & objItem.RegisteredUser & vbCrLf
report = report & "SerialNumber: " & objItem.SerialNumber & vbCrLf
report = report & "ServicePackMajorVersion: " & objItem.ServicePackMajorVersion
report = report & "ServicePackMinorVersion: " & objItem.ServicePackMinorVersion & vbCrLf
report = report & "Version: " & objItem.Version & vbCrLf
report = report & "WindowsDirectory: " & objItem.WindowsDirectory & vbCrLf
Next

Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Memory and Processor Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objComputer in colSettings
'report = report & objComputer.Name & vbcrlf
report = report & objComputer.TotalPhysicalMemory /1024\1024+1 & "MB Total memory" & vbcrlf
Next
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_Processor")
For Each objProcessor in colSettings
report = report & objProcessor.Description & " Processor" & vbCrLf
Next

Set cInstances = GetObject("winmgmts:{impersonationLevel=impersonate}//" &_
strComputer & "/root/cimv2:Win32_Service").Instances_
'********************************
'*** Enumerate instances in the loop, for each, list relevant properties
report = report & vbCrLf & "******************************************" & vbCrLf



report = report & "Disk Drive Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf

Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
report = report & objLogicalDisk.FreeSpace /1024\1024+1 & "MB Free Disk Space" & vbCrLf
report = report & objLogicalDisk.Size /1024\1024+1 & "MB Total Disk Space" & vbCrLf

oReg.EnumKey HKEY_LOCAL_MACHINE, UnInstPath, arrSubKeys


Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile (strComputer & ".txt", ForWriting)
ts.write report
ts.write software
'MsgBox Report
MsgBox "Report has been created"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top