How to Get HP Inventory Information Into the SMP 7.1 Database
This will be useful to any HP shops out there. This article explains how to set up a custom data class and script to gather warranty information from HP computers and record this information into the CMDB. The vbscript obtains the machine's product number and serial number via WMI calls, passes this information to HP's warranty check website, and parses the resulting HTML to get warranty details. To accomplish this, we need to first define a custom data class in the CMDB, then create the task to be run on your machines.
Creating the custom data class
- In the SMP console, open Settings -> All Settings
- Drill down to Discovery and Inventory -> Inventory Solution -> Manage Custom Data Classes
- Click the New Data Class button and name the data class "HP Warranty Information"
- Next, add the following attributes to the HP Warranty Information data class:
Serial Number, Data Type = String, Size = 25, Key = No, Required = No
Product Number, Data Type = String, Size = 25, Key = No, Required = No
Line, Data Type = String, Size = 50, Key = No, Required = No
Description, Data Type = String, Size = 50, Key = No, Required = No
Date Updated, Data Type = Date, Size = 8, Key = No, Required = No
Warranty Type, Data Type = String, Size = 50, Key = No, Required = No
Warranty Start, Data Type = Date, Size = 8, Key = No, Required = No
Warranty End, Data Type = Date, Size = 8, Key = No, Required = No
- Once all of the attributes have been created, click the "finger" button (next to New Data Class) to view the details for the data class
- Write down or copy the guid of the data class into Notepad, as you'll need this later in the script
At this point, you should see a new table in your CMDB, and it should be called "Inv_HP_Warranty_Information" -- you can verify this by opening SQL Server Management Studio, creating a new query against the Symantec_CMDB database of "select * from Inv_HP_Warranty_Information" and seeing 0 rows returned. You can also go into Settings -> Notification Server -> Resource and Data Class Settings -> Data Classes -> Inventory -> Custom -> HP Warranty Information. Opening the data class from this location will give you the guid as well as the table name, should you need either for future reference.
Most of the fields in this data class are self-explanatory. The "Line" and "Description" fields are a little cryptic, though. Line is a more generic description for the product line of the computer. The description lumps together a lot of the details about the computer, such as processor, memory, and hard drive.
The attached text file is the vbscript you will use to create a task in the SMP. You'll want to open this file up in a text editor and on line 7 replace xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx with the guid from your data class you created above prior to pasting this into the SMP.
Once that is done, now would be a good time to do a reality check to make sure everything is working and run this vbscript manually on a managed computer to ensure the database is being populated properly. To do this, you can save that edited file as a .vbs file on an Altiris-managed HP computer, i.e. hpwarranty.vbs, drop to a command prompt and run "cscript hpwarranty.vbs" -- when you run this, you should see no output from the script itself and be returned to the command prompt within a few seconds of running it.
Once this is done, you can either open SQL Server Management Studio and re-run the query mentioned above, or open Resource Manager on the computer record. When you have Resource Manager open, go to View -> Inventory, then expand Data Classes -> Inventory -> Custom -> HP Warranty Information.
If you see data here, then you're good to plow forward and create the inventory task!
- In the SMP console, go to Manage -> Jobs and Tasks
- Right-click Jobs and Tasks and choose New -> Task
- Scroll down and click the Run Script task
- In the task title (currently "Run Script"), change the name to "Gather HP Warranty Information" or similar
- Change the Script Type to VBScript
- Paste your script with the correct guid into the script window
- Click the Advanced button
- In the "Other" section, change Show Script to Hidden
- Click OK twice to save the new task
If you want to do one more reality check, do a Quick Run of the script on a different managed HP machine to validate that the task is running properly. Again, you can go into SQL Server Management Studio or Resource Manager to validate the results.
Now that the task is created, you just need to create a schedule and a target that meets the needs of your organization. As we only have HP workstations reporting into our SMP, I just targeted the Windows Computers filter and I was good to go, but for others who may have mixed environments, you may need to tweak your target to meet your needs. With the data in the CMDB, you are now open to do things like create custom reports with this information.
To give credit where credit is due, the original vbscript was not created by me, but obtained from a blog related to getting this same information into SCCM. I just heavily modified it to make it work with this implementation. Provided HP doesn't make any big changes to their warranty site, this script should work but if they decide to change anything, this script will most likely stop working properly.