This is a nearly finished UDF, based on the previous posts in this topic.
How about keeping all hapy
Create a function that returns a two element array contaning chassis type and description.
Chassis type would be:- Portable
- Desktop
- Server/Expansion
- Unknown
- Not found
Code and sample use:
code:
$st = SystemType('WS03')
'System type: ' + $st[0] ?
'System description: ' + $st[1] ?
Get $
Function SystemType(Optional $WS)
Dim $SysType,$oWMIService,$cItems,$Item,$cType
$cType = 0
$SystemType = 'Not Found'
$SysType = Split('Unknown|Other|Unknown|Desktop|Low Profile Desktop|Pizza Box|Mini Tower|Tower|Portable|'+
'Laptop|Notebook|Hand Held|Docking Station|All in One|Sub Notebook|Space-Saving|'+
'Lunch Box|Main System Chassis|Expansion Chassis|SubChassis|Bus Expansion Chassis|'+
'Peripheral Chassis|Storage Chassis|Rack Mount Chassis|Sealed-Case PC','|')
If Not $WS
$WS = "."
EndIf
$oWMIService = GetObject("winmgmts:\\" + $WS + "\root\cimv2")
If $oWMIService
$cItems = $oWMIService.ExecQuery("Select * from Win32_SystemEnclosure")
For Each $oItem In $cItems
For Each $Item In $oItem.ChassisTypes
$cType = Val($Item)
Next
Next
Select
Case AScan(Split('8,9,10,11,12,13,14',','),$cType) >= 0
$SystemType = 'Portable'
Case AScan(Split('3,4,6,7,15,24',','),$cType) >= 0
$SystemType = 'Desktop'
Case AScan(Split('5,16,17,18,19,20,21,22,23',','),$cType) >= 0
$SystemType = 'Server/Expansion'
Case 1
$SystemType = 'Unknown'
EndSelect
EndIf
$SystemType = Split($SystemType + Chr(9) + $SysType[$cType], Chr(9))
EndFunction
Any comments on whitch type belongs to whitch chassis type ?
-Erik