I am have troubles with this! Guess i am not quite getting it. This is what i have manageg to put together from the postings above. The script runs but nothing happens in the table. Is there any other dependencies. here is the code
code:
$objWMIService = GetObject( "winmgmts://./root/cimv2" )
If @ERROR
GoTo ShowError
EndIf
$colItem1 = $objWMIService.ExecQuery( "Select * from Win32_Processor", , 48 )
$colItem2 = $objWMIService.ExecQuery( "Select * from Win32_LogicalMemoryConfiguration", , 48 )
$colItem3 = $objWMIService.ExecQuery( "Select * from Win32_DiskDrive", , 48 )
For Each $objItem In $colItem1
$clockspeed = $objItem.CurrentClockSpeed
Next
For Each $objItem In $colItem2
$memory=( ( $objItem.TotalPhysicalMemory + 1023 ) / 1024 )
Next
For Each $objItem In $colItem3
$hd = $objItem.Size
$hdgb = Left($hd,Len($hd)-9)
Next
$IEVersion = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer","Version")
$Freespace = GetDiskSpace("C:\") /1024
; Checking for Office Version
CD "c:\program files\microsoft office\office"
$ver = GetFileVersion("excel.exe","fileversion")
If @error = 0
Select
Case SubStr("$ver",1,1) = 8
$officever = "Office 97"
Case SubStr("$ver",1,1) = 9
$Officever = "Office 2000 Professional"
EndSelect
EndIf
$DATABASE = "x:\cvhp.mdb"
$DSN = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=$DATABASE"
$Connection = CreateObject("ADODB.Connection")
$Command = CreateObject("ADODB.Command")
$Recordset = CreateObject("ADODB.Recordset")
;Check for connection object
$Connection.ConnectionString = $DSN
$Connection.Open() ;Open connection to database
$Command.ActiveConnection = $Connection
$Recordset.CursorType = 3
$Recordset.LockType = 3
$Recordset.ActiveCommand = $Command
$Command.CommandText = "SELECT * FROM tbl_Inventory WHERE Mac_Address='@ADDRESS';"
$Recordset.Open($Command)
If $Recordset.RecordCount < 1
$Recordset.AddNew
EndIf
$Recordset.Fields("Mac_Address").Value = @ADDRESS
$Recordset.Fields("Date").Value = @Date
$Recordset.Fields("Campus").Value = $Campus
$Recordset.Fields("IP_Address").Value = @IPADDRESS0
$Recordset.Fields("User_Name").Value = @WUSERID
$Recordset.Fields("Workstation").Value = @WKSTA
$Recordset.Fields("Processor").Value = $clockspeed+" MHZ"
$Recordset.Fields("Memory").Value = $Memory+" MB"
$Recordset.Fields("Hard_Drive").Value = $hdgb+" GB"
$Recordset.Fields("Free_Space").Value = $FREESPACE
$Recordset.Fields("Operating_System").Value = @PRODUCTTYPE
$Recordset.Fields("Service_Pack").Value = @CSD
$Recordset.Fields("Internet _Explorer").Value= $IEVERSION
$Recordset.Fields("Office_Version").Value = $OFFICEVER
$Recordset.Update
$Recordset.Close()