List Hardware Info for Dell and Lenovo

This is a short Powershell script to display hardware information about Dell and Lenovo models. When creating scripts to gather information about Lenovo systems, please notice that the descriptive model information is stored in a different WMI class.

Typically, OEM vendors store descriptive model information under the Win32_ComputerSystem class. With Lenovo, the descriptive model (e.g. ThinkPad X1 Carbon) is stored in the Win32_ComputerSystemProduct class. In addition, Lenovo also uses a 4 digit value to describe configurations called “Machine Type”. This value is often required to look up warranty information online.

$BIOS = Get-WmiObject -Class Win32_BIOS
$System = Get-WmiObject -Class Win32_ComputerSystem
$CSP = Get-WmiObject -Class Win32_ComputerSystemProduct

clear-host

If ($System.Manufacturer.ToLower().Contains("lenovo"))
 {
'Manufacturer: ' + $System.Manufacturer
'Model: ' + $CSP.Version.TrimEnd()
'Machine Type: ' + $System.Model.substring(0,4)
'Serial Number: ' + $BIOS.SerialNumber
 }
Else
{
'Manufacturer: ' + $System.Manufacturer
'Model: ' + $System.Model.TrimEnd()
'Serial Number: ' + $BIOS.SerialNumber
}

Sample Output:

List Hardware Info for Dell and Lenovo

List Hardware Info for Dell and Lenovo