Retrieving Identifying Information by Using the SMBIOS

Microsoft® Windows® 2000 Scripting Guide

Computers are typically identified by name. This practice provides a convenient way to distinguish one computer from another, but it is not always sufficient for uniquely identifying computers; after all, computer names are easily, and often, changed. To track individual computers, you should always use a more immutable identifier, such as the serial number or the asset tag number.

The SMBIOS specification enables manufacturers to store extended information in the BIOS, including unique identifiers such as the serial number and the asset tag number. Retrieving the serial number or the asset tag number can help identify a specific computer. For example, each computer has a unique serial number that does not change unless the BIOS is replaced. Because you are far less likely to replace a BIOS than to rename a computer, the BIOS serial number provides a good way to identify computers.

Identifying information such as serial number and asset tag can be retrieved from a computer by using the WMI Win32_SystemEnclosure class.

Note

  • A number of third-party tools can also retrieve extended BIOS information. However, most of these tools are hardware-specific; before the SMBIOS specifications were completed, many hardware manufacturers stored the serial number and asset tag in nonstandard formats. The Win32_SystemEnclosure class can generally retrieve this information, even if it has been stored in a nonstandard way.

Table 8.3 lists the SMBIOS-related properties of the Win32_SystemEnclosure class.

Table 8.3 Win32_SystemEnclosure Properties

Property

Description

PartNumber

Part number assigned by the organization responsible for producing or manufacturing the computer.

SerialNumber

Manufacturer-allocated number used to identify the computer.

SKU

Stock-keeping unit number for the computer.

SMBIOSAssetTag

Asset tag number of the computer.

Scripting Steps

Listing 8.3 contains a script that retrieves identifying information for a computer. To carry out this task, the script must perform the following steps:

  1. Create a variable to specify the computer name.

  2. Use a GetObject call to connect to the WMI namespace root\cimv2, and set the impersonation level to "impersonate."

  3. Use the ExecQuery method to query the Win32_SystemEnclosure class.

    This query returns a collection consisting of the physical properties of the computer and its housing.

  4. Echo the values for PartNumber, SerialNumber, and SMBIOSAssetTag.

Listing 8.3 Retrieving Identifying Information

  
1
2
3
4
5
6
7
8
9
10
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
 Wscript.Echo "Part Number: " & objSMBIOS.PartNumber
 Wscript.Echo "Serial Number: " & objSMBIOS.SerialNumber
 Wscript.Echo "Asset Tag: " & objSMBIOS.SMBIOSAssetTag
Next