OCS Inventory NG – usefull SQL scripts

Most important tables:
accountinfo – main table witch contain ID of device
[HARDWARE_ID] [TAG] [fields_4] [fields_5] [fields_6]…

hardware – OS info.
[ID] [DEVICEID] [NAME] [WORKGROUP] [USERDOMAIN] [OSNAME] [OSVERSION] [OSCOMMENTS] [PROCESSORT] [] ……

bios – hardware info.
[HARDWARE_ID] [] [] [] [] [] [] [] …….

itmgmt_comments – commants, very usefull

Notes: It is possible to create Your own fields, for example Inventory number assigned inside company for every device. In this case fields_4. Those fields are created in accountinfo table.

Usefull SQL scripts:
Select computer info witch self assigned inventory number:

SELECT accountinfo.HARDWARE_ID, accountinfo.TAG, accountinfo.fields_4, itmgmt_comments.COMMENTS, itmgmt_comments.USER_INSERT
FROM accountinfo
JOIN itmgmt_comments
ON accountinfo.HARDWARE_ID = itmgmt_comments.HARDWARE_ID

Select every computer with administrator credential account which name is other then ‚superuser’, ‚admin’, ‚Administrator’

SELECT accountinfo.HARDWARE_ID, accountinfo.TAG, accountinfo.fields_4, winusers.name, winusers.TYPE, hardware.name, hardware.IPADDR
FROM accountinfo
JOIN winusers
ON accountinfo.HARDWARE_ID = winusers.HARDWARE_ID
JOIN hardware
ON winusers.HARDWARE_ID = hardware.ID
WHERE winusers.TYPE = 'Admin'
AND winusers.NAME NOT IN ('superuser', 'su', 'admin', 'Administrator')

Select computers with BIOS S/N and inventory number (fields_4)

select bios.SMODEL, bios.ssn, accountinfo.TAG, accountinfo.fields_4
FROM bios
JOIN accountinfo
ON bios.HARDWARE_ID = accountinfo.HARDWARE_ID 
WHERE bios.SSN LIKE'%DTV%'

Select computers with low disk space (less then 2 GB):

Select NAME, LETTER, Free from drives JOIN hardware ON hardware.id = drives.hardware_id where drives.free <2000 and drives.letter like 'C:'

Set inventory number and TAG to computer witch ID:

update accountinfo set TAG='', fields_4='' where hardware_id='';