Page 1 of 1 1
Topic Options
#70502 - 2002-10-02 09:48 PM Inventory
Wokkeltje Offline
Fresh Scripter

Registered: 2002-08-12
Posts: 31
Loc: Torhout, Belgium
First of al, you need an Access database with 2 tables, first table 'COMPUTERS', the second 'LOGON'. Details see script.

code:
	If @INWIN = 1
$DriveSpace = GetDiskSpace(ExpandEnvironmentVars('%SystemDrive%'))/1024
Else
$DriveSpace = GetDiskSpace("C:\")/1024
EndIf
If KeyExist("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBEM") AND KeyExist("HKEY_CLASSES_ROOT\WINMGMTS")
$Manufacturer = WMIQuery("Manufacturer","Win32_ComputerSystem")
$Model = WMIQuery("Model","Win32_ComputerSystem")
$SerialNumber = WMIQuery("SerialNumber","Win32_BIOS")
$BIOSVersion = WMIQuery("SMBIOSBIOSVersion","Win32_BIOS")
$BIOSDate = WMIQuery("Version","Win32_BIOS")
$CPUSpeed = WMIQuery("CurrentClockSpeed","Win32_Processor")
$CPUSpeed = "$CPUSpeed Mhz"
$SystemMemory = Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024
$SystemMemory = "$SystemMemory MB"
$DimmSize = ""
For Each $dimm in Split(WMIQuery("Capacity","Win32_PhysicalMemory"),"|")
$dimm = Val($dimm) / 1048576
If $DimmSize = ""
$DimmSize = "$dimm MB"
Else
$DimmSize = "$DimmSize + $dimm MB"
EndIf
Next
$VideoCard = WMIQuery("Description","Win32_VideoController")
$VideoRes = WMIQuery("VideoModeDescription","Win32_VideoController")
$Modem = WMIQuery("Description","Win32_POTSModem")
$NICs = ""
For Each $nic in Split(WMIQuery("ProductName","Win32_NetworkAdapter"),"|")
If InStr($nic,"miniport")=0 AND InStr($nic,"minipoort")=0 AND InStr($nic,"RAS")=0 AND InStr($nic,"Parallel")=0 AND InStr($nic,"VMware")=0
If $NICs =""
$NICs = "$nic"
Else
$NICs = "$NICs@crlf$nic"
EndIf
EndIf
Next
EndIf

$DBpath = "\\Server\Share\Logon.mdb"
$cn = CreateObject ("ADODB.Connection")
$cmd = CreateObject ("ADODB.Command")
$rs = CreateObject ("ADODB.RecordSet")
$cn.connectionstring = "provider=microsoft.jet.oledb.4.0;data source=$DBpath;persist security info=false"
$cn.Open
$cmd.activeconnection = $cn
$rs.cursortype = 3
$rs.locktype = 3
$rs.activecommand = $cmd

$cmd.commandtext = "select * from COMPUTERS where computername = '@WKSTA'"

$rs.Open ($cmd)
If $rs.eof = -1 ; addnew is only needed if a record for this workstation was not found.
$rs.addnew
EndIf
$rs.fields.item("computername").value = @WKSTA
$rs.fields.item("username").value = @USERID
$rs.fields.item("OS").value = @PRODUCTTYPE
$rs.fields.item("SP").value = @CSD
$rs.fields.item("drivespace").value = $DriveSpace
$rs.fields.item("ipadress").value = @IPADDRESS0
$rs.fields.item("MACadress").value = @ADDRESS
$rs.fields.item("Manufacturer").value = $Manufacturer
$rs.fields.item("Model").value = $Model
$rs.fields.item("SerialNumber").value = $SerialNumber
$rs.fields.item("BIOSVersion").value = $BIOSVersion
$rs.fields.item("BIOSDate").value = $BIOSDate
$rs.fields.item("CPUSpeed").value = $CPUSpeed
$rs.fields.item("SystemMemory").value = $SystemMemory
$rs.fields.item("DimmSize").value = $DimmSize
$rs.fields.item("VideoCard").value = $VideoCard
$rs.fields.item("VideoRes").value = $VideoRes
$rs.fields.item("Modem").value = $Modem
$rs.fields.item("NICs").value = $NICs
$rs.update
$rs.Close

$cmd.commandtext = "insert into LOGON values('@DATE','@TIME','@WKSTA','@USERID','@LSERVER','@IPADDRESS0')"

$rs.Open ($cmd)
$rs.Close

code:
Function WMIQuery($what,$where, optional $computer)	
Dim $strQuery, $objEnumerator, $value
If NOT $computer
$computer="@WKSTA"
EndIf
$strQuery = "Select $what From $where"
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//$computer")
$objEnumerator = $SystemSet.ExecQuery($strQuery)
For Each $objInstance in $objEnumerator
If @Error = 0 AND $objInstance <> ""
$nul=Execute("$$value = $$objInstance.$what")
$WMIQuery="$value"+"|"+"$WMIQuery"
EndIf
Next
$WMIQuery=Left($WMIQuery,Len($WMIQuery)-1)
EndFunction

First of all I want to thank everyone who posted small scripts that I could use to create the complete inventory.

But now the problem, The script nly work with version 4.02 of KiXtart. What has changed in the newer versions why it wont work anymore.

A second question. I use this in the logonscript, but it won't work on al the PC's. There are problems on Win NT 4.0 Workstations, but therefore I put the test to see if the WMI Core 1.5 software was installed. But also not all the newly installed Win2000 Prof SP2 machines would post their data to the database. The strange thing is that al the new PC's are installed on the same way (with an unattended setup, so every PC has the same Softwarebundle)

Someone has an idea or some remarks on the script? Because for me COM objects and WMI are not verry known.

tnx

Top
#70503 - 2002-10-03 08:18 AM Re: Inventory
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Wokkeltje,

quote:

But now the problem, The script nly work with version 4.02 of KiXtart. What has changed in the newer versions why it wont work anymore.

It is known about your issue with Database COM. I have heard that this has been addressed in 4.12b.

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 671 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.051 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org