CPU Custom Inventory
search cancel

CPU Custom Inventory


Article ID: 282592


Updated On:


Inventory Solution


This example uses a vbscript to pull CPU data from the Win32_Processor class using a WMI query.

Note there are many attributes available to collect - see the Microsoft article, Win32_Processor class 


  1. Create a new custom data class that will store the file information for each computer.
    1. Go to Settings>All Settings then Settings>Discovery and Inventory>Inventory Solution>Manage Custom Data Classes.
    2. Click New data class.
    3. Name the data class something appropriate and click OK. Use this exact data class name later in the custom inventory script.
    4. Click Add attribute.
    5. Name the attribute "ComputerName", set Key to "No", and click OK.
    6. Add another attribute the same way named "MaxClockSpeed".
    7. Add another attribute the same way named "InventoryDate".
    8. Click Save Changes.
    9. Go to Settings>All Settings>Discovery and Inventory>Manage Custom Data Classes. In the middle panel highlight the custom data class created in step A above (in our example, and click on the  icon. You will see the Data Class Details dialog box pop up. Copy the Table Name and the GUID to a text file.
  2. Create a Custom Inventory Script Task.
    1. Go to Manage>Jobs and Tasks.
    2. Browse the folder drop-down menu to where you would like to add a custom inventory script task.
    3. Right-click on the folder, then select New>Task.
    4. Select the Run Script task.
    5. Name the task appropriately.
    6. Select Script type: VBScript.
    7. Copy and paste the entire VBScript below into the large text box of the script task. Then edit the script to use the custom data class created in step 1-3, and the full path and name of the desired file.

'      On Error Resume Next

'Create instance of Wbem service object and connect to namespace
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Get the computer name
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )

'Fire WMI Query
Set objCIMObj = objWMIService.ExecQuery("Select * from Win32_Processor")


'Create instance of Altiris NSE component
dim nse
set nse = WScript.CreateObject ("Altiris.AeXNSEvent")

' Set the header data of the NSE
' Please don't modify this GUID
nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
nse.Priority = 1

'Create Inventory data block. Here assumption is that the data class with below guid is already configured on server
dim objDCInstance
set objDCInstance = nse.AddDataClass ("{GUID}") '****Your Custom Data Class GUID, leave brackets

dim objDataClass
set objDataClass = nse.AddDataBlock (objDCInstance)

For each objInfo in objCIMObj

'Add a new row
dim objDataRow
set objDataRow = objDataClass.AddRow
'Set columns

objDataRow.SetField 0, CStr(strComputerName)
objDataRow.SetField 1, objInfo.Manufacturer
objDataRow.SetField 2, objInfo.MaxClockSpeed
objDataRow.SetField 3, objInfo.Name
objDataRow.SetField 4, objInfo.NumberOfCores
objDataRow.SetField 5, objInfo.NumberOfLogicalProcessors
objDataRow.SetField 6, objInfo.Version
objDataRow.SetField 7, cstr(now)

MsgBox nse.Xml    'Uncomment for testing on local machine