inventory: report device class (form factor)
build-windows / build-hello-agent-x64 (push) Successful in 6m43s
build-windows / sign-hello-agent-x64 (push) Successful in 6s
build-windows / validate-hello-agent-x64 (push) Successful in 10s

Derive a coarse device_class from SMBIOS chassis type + PCSystemType, with
VM detection (manufacturer/model) and Windows Server OS taking precedence:
Laptop / Desktop / Server / Tablet / Virtual Machine / Unknown. Surfaced in
opsbase on the device list and Hardware tab.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-18 11:41:54 +00:00
parent 95e51842ae
commit b5e8c00d92
+32
View File
@@ -154,10 +154,42 @@ $installed_software = @($installed_software | Sort-Object name, version)
$os_release = "$($os.Version)"
if ($displayVersion) { $os_release = "$($os.Version) $displayVersion" }
# Device class — a coarse form factor for asset grouping. VM first (most
# specific), then Windows Server OS, then the SMBIOS chassis type, then the
# computer-system PCSystemType as a fallback.
$enc = Get-CimInstance -ClassName Win32_SystemEnclosure -ErrorAction SilentlyContinue | Select-Object -First 1
$chassis = @(); if ($enc) { $chassis = @($enc.ChassisTypes) }
$man = "$($cs.Manufacturer)".ToLower()
$mod = "$($cs.Model)".ToLower()
$device_class = 'Unknown'
if ($man -match 'vmware|virtualbox|innotek|qemu|xen|parallels|kvm' -or $mod -match 'virtual machine|vmware|virtualbox|kvm|qemu') {
$device_class = 'Virtual Machine'
} elseif ("$($os.Caption)" -match 'Server') {
$device_class = 'Server'
} else {
foreach ($ct in $chassis) {
if ($ct -in 8,9,10,14) { $device_class = 'Laptop'; break }
elseif ($ct -in 30,31,32) { $device_class = 'Tablet'; break }
elseif ($ct -in 17,23,28,29) { $device_class = 'Server'; break }
elseif ($ct -in 3,4,5,6,7,13,15,16,24) { $device_class = 'Desktop'; break }
}
if ($device_class -eq 'Unknown') {
switch ([int]$cs.PCSystemType) {
1 { $device_class = 'Desktop' }
2 { $device_class = 'Laptop' }
3 { $device_class = 'Desktop' }
4 { $device_class = 'Server' }
5 { $device_class = 'Server' }
}
}
}
$result = [pscustomobject]@{
serial_number = $bios.SerialNumber
manufacturer = $cs.Manufacturer
model = $cs.Model
device_class = $device_class
domain = $cs.Domain
os_distro = $os.Caption
os_release = $os_release