ALERT: Some images may not load properly within the Knowledge Base Article. If you see a broken image, please right-click and select 'Open image in a new tab'. We apologize for this inconvenience.

Hardware Inventory Returns a Different Model

book

Article ID: 162595

calendar_today

Updated On:

Products

Inventory Solution

Issue/Introduction

In some cases there is more than one model available on a Windows computer depending on how the computer manufacturer configures WMI dataclasses. 

Resolution

To collect the desired model number a custom inventory may be used. To do this first create a custom data class by following the steps in HOWTO10487. To use the sample Visual Basic (VB) script below, create two attributes (columns) in your new data class – the first one for Computer Name, and second for Model. Ensure that you set the Key Required option to ‘No’ for Model. After saving the new data class, select the new data class and click the hand icon in the menu bar and copy the GUID of the data class and the table name for later use. You will past this into the VB script where indicated.

Create a new script task by going to Manage > Jobs and Tasks, and right clicking on any folder. Select New > Task. Scroll to the bottom and select Run Script. In the pop-up window, put in a suitable Task Name in the top text box. For Script type, change the drop down menu to VBScript. Past the script below into the large text window and click OK.  Then take the GUID from the custom data class and paste it into the script, replacing the phrase, “PASTE THE CUSTOM DATA CLASS GUID HERE BETWEEN THE BRACKETS”. At this point, make any changes desired in the Advanced area, and then click Save changes. You can now test this by using Quick Run or by using a schedule.

After the test run completes, you can view the data by going to Reports > All Reports. Right click on any folder where you want the report to reside, and select New > Report > SQL Report.Replace the text in the text box with

select * from Inv_CUSTOM_DATA_CLASS_TABLE_NAME

Note that when creating a custom data class, the resultant table name will be preceded by Inv_, and that any spaces in the name will be replaced with underscores.

Click Save Changes and verify the data is as expected.

'*************************************************************************************
' NS8.x Custom inventory VBS script to gather the model number of a Windows computer
'*************************************************************************************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
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. This is the GUID the custom data class created in the console

set objDCInstance = nse.AddDataClass ("{PASTE THE CUSTOM DATA CLASS GUID HERE BETWEEN THE BRACKETS}")
set objDataClass = nse.AddDataBlock (objDCInstance)
set objDataClass = nse.AddDataBlock (objDCInstance)
Set objCIMObj = objWMIService.ExecQuery("SELECT Model FROM Win32_ComputerSystem")
For each objInfo in objCIMObj
            set objDataRow = objDataClass.AddRow
            objDataRow.SetField 0, CStr(strComputerName)
            objDataRow.SetField 1, ObjInfo.Model
Next

nse.Send