-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPCSystemType.ps1
More file actions
39 lines (32 loc) · 1.25 KB
/
PCSystemType.ps1
File metadata and controls
39 lines (32 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<#
.SYNOPSIS
Enumeration of Win32_ComputerSystem.PCSystemType
#>
#([CimSession]::Create('.')).GetClass('ROOT/CIMV2', 'Win32_ComputerSystem',
# [Microsoft.Management.Infrastructure.Options.CimOperationOptions]@{Flags = [Microsoft.Management.Infrastructure.Options.CimOperationFlags]::LocalizedQualifiers})
#exit 0
param([string]$Type)
$session = [CimSession]::Create('.')
try {
# Add operation options that retrieve localized values for mappings
$operationOptions = [Microsoft.Management.Infrastructure.Options.CimOperationOptions]@{
Flags = [Microsoft.Management.Infrastructure.Options.CimOperationFlags]::LocalizedQualifiers
}
$class = $session.GetClass('ROOT/CIMV2', 'Win32_ComputerSystem', $operationOptions)
$qualifiers = $class.CimClassProperties['PCSystemType'].Qualifiers
$mappedQualifiers = @{}
# Keys and values are stored as separate arrays
$keys = $qualifiers['ValueMap'].Value
$values = $qualifiers['Values'].Value
for ($i = 0; $i -lt $keys.Length; $i++) {
$mappedQualifiers[$keys[$i]] = $values[$i]
}
# yield
if ($Type) {
$mappedQualifiers["$Type"]
} else {
$mappedQualifiers
}
} finally {
$session.Dispose()
}