The Win32_CacheMemory WMI class represents internal and external cache memory on a computer system.
Methods
Win32_CacheMemory has no methods. Inherited methods (Reset and SetPowerState) are not implemented.
Properties
Win32_CacheMemory returns 53 properties:
'Access','AdditionalErrorData','Associativity','Availability','BlockSize',
'CacheSpeed','CacheType','Caption','ConfigManagerErrorCode','ConfigManagerUserConfig',
'CorrectableError','CreationClassName','CurrentSRAM','Description','DeviceID','EndingAddress',
'ErrorAccess','ErrorAddress','ErrorCleared','ErrorCorrectType','ErrorData','ErrorDataOrder',
'ErrorDescription','ErrorInfo','ErrorMethodology','ErrorResolution','ErrorTime','ErrorTransferSize',
'FlushTimer','InstallDate','InstalledSize','LastErrorCode','Level','LineSize','Location',
'MaxCacheSize','Name','NumberOfBlocks','OtherErrorDescription','PNPDeviceID',
'PowerManagementCapabilities','PowerManagementSupported','Purpose','ReadPolicy','ReplacementPolicy',
'StartingAddress','Status','StatusInfo','SupportedSRAM','SystemCreationClassName','SystemLevelAddress',
'SystemName','WritePolicy'
Unless explicitly marked as writeable, all properties are read-only. Read all properties for all instances:
Get-CimInstance -ClassName Win32_CacheMemory -Property *
Most WMI classes return one or more instances.
When
Get-CimInstance
returns no result, then apparently no instances of class Win32_CacheMemory exist. This is normal behavior.Either the class is not implemented on your system (may be deprecated or due to missing drivers, i.e. CIM_VideoControllerResolution), or there are simply no physical representations of this class currently available (i.e. Win32_TapeDrive).
Access
Type of access.
Access returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$Access_map = @{
0 = 'Unknown'
1 = 'Readable'
2 = 'Writeable'
3 = 'Read/Write Supported'
4 = 'Write Once'
}
Use a switch statement
switch([int]$value)
{
0 {'Unknown'}
1 {'Readable'}
2 {'Writeable'}
3 {'Read/Write Supported'}
4 {'Write Once'}
default {"$value"}
}
Use Enum structure
Enum EnumAccess
{
Unknown = 0
Readable = 1
Writeable = 2
ReadWrite_Supported = 3
Write_Once = 4
}
Examples
Use $Access_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "Access" to friendly text
Note: to use other properties than "Access", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Access"
# to translate other properties, use their translation table instead
$Access_map = @{
0 = 'Unknown'
1 = 'Readable'
2 = 'Writeable'
3 = 'Read/Write Supported'
4 = 'Write Once'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Access", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Access = @{
Name = 'Access'
Expression = {
# property is an array, so process all values
$value = $_.Access
$Access_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "Access". The latter
# is defined by the hashtable in $Access:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $Access
# ...or dump content of property Access:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $Access |
Select-Object -ExpandProperty Access
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $Access_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$Access_map = @{
0 = 'Unknown'
1 = 'Readable'
2 = 'Writeable'
3 = 'Read/Write Supported'
4 = 'Write Once'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.Access
# translate raw value to friendly text:
$friendlyName = $Access_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "Access" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "Access", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Access", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Access = @{
Name = 'Access'
Expression = {
# property is an array, so process all values
$value = $_.Access
switch([int]$value)
{
0 {'Unknown'}
1 {'Readable'}
2 {'Writeable'}
3 {'Read/Write Supported'}
4 {'Write Once'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "Access". The latter is defined
# by the hashtable in $Access:
Select-Object -Property Caption, $Access
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumAccess
{
Unknown = 0
Readable = 1
Writeable = 2
ReadWrite_Supported = 3
Write_Once = 4
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.Access
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **Access**
[EnumAccess]$rawValue
# get a comma-separated string:
[EnumAccess]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumAccess]
#endregion
Enums must cover all possible values. If Access returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
AdditionalErrorData
Array of octets that hold additional error information. An example is ECC Syndrome or the return of the check bits if a CRC-based error methodology is used. In the latter case, if a single-bit error is recognized and the CRC algorithm is known, it is possible to determine the exact bit that failed. This type of data (ECC Syndrome, Check Bit, Parity Bit data, or other vendor supplied information) is included in this field. If the ErrorInfo property is equal to 3 (OK), then this property has no meaning.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, AdditionalErrorData
Associativity
An integer enumeration that defines the system cache associativity.
This value comes from the Associativity member of the Cache Information structure in the SMBIOS information.
Associativity returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$Associativity_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Direct Mapped'
4 = '2-way Set-Associative'
5 = '4-way Set-Associative'
6 = 'Fully Associative'
7 = '8-way Set-Associative'
8 = '16-way Set-Associative'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Direct Mapped'}
4 {'2-way Set-Associative'}
5 {'4-way Set-Associative'}
6 {'Fully Associative'}
7 {'8-way Set-Associative'}
8 {'16-way Set-Associative'}
default {"$value"}
}
Use Enum structure
Enum EnumAssociativity
{
Other = 1
Unknown = 2
Direct_Mapped = 3
_2_way_Set_Associative = 4
_4_way_Set_Associative = 5
Fully_Associative = 6
_8_way_Set_Associative = 7
_16_way_Set_Associative = 8
}
Examples
Use $Associativity_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "Associativity" to friendly text
Note: to use other properties than "Associativity", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Associativity"
# to translate other properties, use their translation table instead
$Associativity_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Direct Mapped'
4 = '2-way Set-Associative'
5 = '4-way Set-Associative'
6 = 'Fully Associative'
7 = '8-way Set-Associative'
8 = '16-way Set-Associative'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Associativity", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Associativity = @{
Name = 'Associativity'
Expression = {
# property is an array, so process all values
$value = $_.Associativity
$Associativity_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "Associativity". The latter
# is defined by the hashtable in $Associativity:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $Associativity
# ...or dump content of property Associativity:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $Associativity |
Select-Object -ExpandProperty Associativity
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $Associativity_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$Associativity_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Direct Mapped'
4 = '2-way Set-Associative'
5 = '4-way Set-Associative'
6 = 'Fully Associative'
7 = '8-way Set-Associative'
8 = '16-way Set-Associative'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.Associativity
# translate raw value to friendly text:
$friendlyName = $Associativity_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "Associativity" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "Associativity", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Associativity", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Associativity = @{
Name = 'Associativity'
Expression = {
# property is an array, so process all values
$value = $_.Associativity
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Direct Mapped'}
4 {'2-way Set-Associative'}
5 {'4-way Set-Associative'}
6 {'Fully Associative'}
7 {'8-way Set-Associative'}
8 {'16-way Set-Associative'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "Associativity". The latter is defined
# by the hashtable in $Associativity:
Select-Object -Property Caption, $Associativity
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumAssociativity
{
Other = 1
Unknown = 2
Direct_Mapped = 3
_2_way_Set_Associative = 4
_4_way_Set_Associative = 5
Fully_Associative = 6
_8_way_Set_Associative = 7
_16_way_Set_Associative = 8
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.Associativity
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **Associativity**
[EnumAssociativity]$rawValue
# get a comma-separated string:
[EnumAssociativity]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumAssociativity]
#endregion
Enums must cover all possible values. If Associativity returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
Availability
Availability and status of the device.
This value comes from the Cache Configuration member of the Cache Information structure in the SMBIOS information.
Availability returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$Availability_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Running/Full Power'
4 = 'Warning'
5 = 'In Test'
6 = 'Not Applicable'
7 = 'Power Off'
8 = 'Off Line'
9 = 'Off Duty'
10 = 'Degraded'
11 = 'Not Installed'
12 = 'Install Error'
13 = 'Power Save - Unknown'
14 = 'Power Save - Low Power Mode'
15 = 'Power Save - Standby'
16 = 'Power Cycle'
17 = 'Power Save - Warning'
18 = 'Paused'
19 = 'Not Ready'
20 = 'Not Configured'
21 = 'Quiesced'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Running/Full Power'}
4 {'Warning'}
5 {'In Test'}
6 {'Not Applicable'}
7 {'Power Off'}
8 {'Off Line'}
9 {'Off Duty'}
10 {'Degraded'}
11 {'Not Installed'}
12 {'Install Error'}
13 {'Power Save - Unknown'}
14 {'Power Save - Low Power Mode'}
15 {'Power Save - Standby'}
16 {'Power Cycle'}
17 {'Power Save - Warning'}
18 {'Paused'}
19 {'Not Ready'}
20 {'Not Configured'}
21 {'Quiesced'}
default {"$value"}
}
Use Enum structure
Enum EnumAvailability
{
Other = 1
Unknown = 2
RunningFull_Power = 3
Warning = 4
In_Test = 5
Not_Applicable = 6
Power_Off = 7
Off_Line = 8
Off_Duty = 9
Degraded = 10
Not_Installed = 11
Install_Error = 12
Power_Save_Unknown = 13
Power_Save_Low_Power_Mode = 14
Power_Save_Standby = 15
Power_Cycle = 16
Power_Save_Warning = 17
Paused = 18
Not_Ready = 19
Not_Configured = 20
Quiesced = 21
}
Examples
Use $Availability_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "Availability" to friendly text
Note: to use other properties than "Availability", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Availability"
# to translate other properties, use their translation table instead
$Availability_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Running/Full Power'
4 = 'Warning'
5 = 'In Test'
6 = 'Not Applicable'
7 = 'Power Off'
8 = 'Off Line'
9 = 'Off Duty'
10 = 'Degraded'
11 = 'Not Installed'
12 = 'Install Error'
13 = 'Power Save - Unknown'
14 = 'Power Save - Low Power Mode'
15 = 'Power Save - Standby'
16 = 'Power Cycle'
17 = 'Power Save - Warning'
18 = 'Paused'
19 = 'Not Ready'
20 = 'Not Configured'
21 = 'Quiesced'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Availability", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Availability = @{
Name = 'Availability'
Expression = {
# property is an array, so process all values
$value = $_.Availability
$Availability_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "Availability". The latter
# is defined by the hashtable in $Availability:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $Availability
# ...or dump content of property Availability:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $Availability |
Select-Object -ExpandProperty Availability
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $Availability_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$Availability_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Running/Full Power'
4 = 'Warning'
5 = 'In Test'
6 = 'Not Applicable'
7 = 'Power Off'
8 = 'Off Line'
9 = 'Off Duty'
10 = 'Degraded'
11 = 'Not Installed'
12 = 'Install Error'
13 = 'Power Save - Unknown'
14 = 'Power Save - Low Power Mode'
15 = 'Power Save - Standby'
16 = 'Power Cycle'
17 = 'Power Save - Warning'
18 = 'Paused'
19 = 'Not Ready'
20 = 'Not Configured'
21 = 'Quiesced'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.Availability
# translate raw value to friendly text:
$friendlyName = $Availability_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "Availability" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "Availability", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Availability", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Availability = @{
Name = 'Availability'
Expression = {
# property is an array, so process all values
$value = $_.Availability
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Running/Full Power'}
4 {'Warning'}
5 {'In Test'}
6 {'Not Applicable'}
7 {'Power Off'}
8 {'Off Line'}
9 {'Off Duty'}
10 {'Degraded'}
11 {'Not Installed'}
12 {'Install Error'}
13 {'Power Save - Unknown'}
14 {'Power Save - Low Power Mode'}
15 {'Power Save - Standby'}
16 {'Power Cycle'}
17 {'Power Save - Warning'}
18 {'Paused'}
19 {'Not Ready'}
20 {'Not Configured'}
21 {'Quiesced'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "Availability". The latter is defined
# by the hashtable in $Availability:
Select-Object -Property Caption, $Availability
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumAvailability
{
Other = 1
Unknown = 2
RunningFull_Power = 3
Warning = 4
In_Test = 5
Not_Applicable = 6
Power_Off = 7
Off_Line = 8
Off_Duty = 9
Degraded = 10
Not_Installed = 11
Install_Error = 12
Power_Save_Unknown = 13
Power_Save_Low_Power_Mode = 14
Power_Save_Standby = 15
Power_Cycle = 16
Power_Save_Warning = 17
Paused = 18
Not_Ready = 19
Not_Configured = 20
Quiesced = 21
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.Availability
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **Availability**
[EnumAvailability]$rawValue
# get a comma-separated string:
[EnumAvailability]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumAvailability]
#endregion
Enums must cover all possible values. If Availability returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
BlockSize
Size in bytes of the blocks that form this storage extent. If unknown or if a block concept is not valid (for example, for aggregate extents, memory, or logical disks), enter a 1.
For more information about using uint64 values in scripts, see Scripting in WMI.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, BlockSize
CacheSpeed
Speed of the cache.
This value comes from the Cache Speed member of the Cache Information structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, CacheSpeed
CacheType
Type of cache.
This value comes from the System Cache Type member of the Cache Information structure in the SMBIOS information.
CacheType returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$CacheType_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Instruction'
4 = 'Data'
5 = 'Unified'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Instruction'}
4 {'Data'}
5 {'Unified'}
default {"$value"}
}
Use Enum structure
Enum EnumCacheType
{
Other = 1
Unknown = 2
Instruction = 3
Data = 4
Unified = 5
}
Examples
Use $CacheType_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "CacheType" to friendly text
Note: to use other properties than "CacheType", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "CacheType"
# to translate other properties, use their translation table instead
$CacheType_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Instruction'
4 = 'Data'
5 = 'Unified'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "CacheType", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$CacheType = @{
Name = 'CacheType'
Expression = {
# property is an array, so process all values
$value = $_.CacheType
$CacheType_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "CacheType". The latter
# is defined by the hashtable in $CacheType:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $CacheType
# ...or dump content of property CacheType:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $CacheType |
Select-Object -ExpandProperty CacheType
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $CacheType_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$CacheType_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Instruction'
4 = 'Data'
5 = 'Unified'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.CacheType
# translate raw value to friendly text:
$friendlyName = $CacheType_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "CacheType" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "CacheType", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "CacheType", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$CacheType = @{
Name = 'CacheType'
Expression = {
# property is an array, so process all values
$value = $_.CacheType
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Instruction'}
4 {'Data'}
5 {'Unified'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "CacheType". The latter is defined
# by the hashtable in $CacheType:
Select-Object -Property Caption, $CacheType
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumCacheType
{
Other = 1
Unknown = 2
Instruction = 3
Data = 4
Unified = 5
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.CacheType
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **CacheType**
[EnumCacheType]$rawValue
# get a comma-separated string:
[EnumCacheType]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumCacheType]
#endregion
Enums must cover all possible values. If CacheType returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
Caption
Short description of the object a one-line string.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, Caption
ConfigManagerErrorCode
Win32 Configuration Manager error code.
ConfigManagerErrorCode returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$ConfigManagerErrorCode_map = @{
0 = 'This device is working properly.'
1 = 'This device is not configured correctly.'
2 = 'Windows cannot load the driver for this device.'
3 = 'The driver for this device might be corrupted, or your system may be running low on memory or other resources.'
4 = 'This device is not working properly. One of its drivers or your registry might be corrupted.'
5 = 'The driver for this device needs a resource that Windows cannot manage.'
6 = 'The boot configuration for this device conflicts with other devices.'
7 = 'Cannot filter.'
8 = 'The driver loader for the device is missing.'
9 = 'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'
10 = 'This device cannot start.'
11 = 'This device failed.'
12 = 'This device cannot find enough free resources that it can use.'
13 = 'Windows cannot verify this device''s resources.'
14 = 'This device cannot work properly until you restart your computer.'
15 = 'This device is not working properly because there is probably a re-enumeration problem.'
16 = 'Windows cannot identify all the resources this device uses.'
17 = 'This device is asking for an unknown resource type.'
18 = 'Reinstall the drivers for this device.'
19 = 'Failure using the VxD loader.'
20 = 'Your registry might be corrupted.'
21 = 'System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.'
22 = 'This device is disabled.'
23 = 'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'
24 = 'This device is not present, is not working properly, or does not have all its drivers installed.'
25 = 'Windows is still setting up this device.'
26 = 'Windows is still setting up this device.'
27 = 'This device does not have valid log configuration.'
28 = 'The drivers for this device are not installed.'
29 = 'This device is disabled because the firmware of the device did not give it the required resources.'
30 = 'This device is using an Interrupt Request (IRQ) resource that another device is using.'
31 = 'This device is not working properly because Windows cannot load the drivers required for this device.'
}
Use a switch statement
switch([int]$value)
{
0 {'This device is working properly.'}
1 {'This device is not configured correctly.'}
2 {'Windows cannot load the driver for this device.'}
3 {'The driver for this device might be corrupted, or your system may be running low on memory or other resources.'}
4 {'This device is not working properly. One of its drivers or your registry might be corrupted.'}
5 {'The driver for this device needs a resource that Windows cannot manage.'}
6 {'The boot configuration for this device conflicts with other devices.'}
7 {'Cannot filter.'}
8 {'The driver loader for the device is missing.'}
9 {'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'}
10 {'This device cannot start.'}
11 {'This device failed.'}
12 {'This device cannot find enough free resources that it can use.'}
13 {'Windows cannot verify this device''s resources.'}
14 {'This device cannot work properly until you restart your computer.'}
15 {'This device is not working properly because there is probably a re-enumeration problem.'}
16 {'Windows cannot identify all the resources this device uses.'}
17 {'This device is asking for an unknown resource type.'}
18 {'Reinstall the drivers for this device.'}
19 {'Failure using the VxD loader.'}
20 {'Your registry might be corrupted.'}
21 {'System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.'}
22 {'This device is disabled.'}
23 {'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'}
24 {'This device is not present, is not working properly, or does not have all its drivers installed.'}
25 {'Windows is still setting up this device.'}
26 {'Windows is still setting up this device.'}
27 {'This device does not have valid log configuration.'}
28 {'The drivers for this device are not installed.'}
29 {'This device is disabled because the firmware of the device did not give it the required resources.'}
30 {'This device is using an Interrupt Request (IRQ) resource that another device is using.'}
31 {'This device is not working properly because Windows cannot load the drivers required for this device.'}
default {"$value"}
}
Use Enum structure
Enum EnumConfigManagerErrorCode
{
This_device_is_working_properly = 0
This_device_is_not_configured_correctly = 1
Windows_cannot_load_the_driver_for_this_device = 2
The_driver_for_this_device_might_be_corrupted_or_your_system_may_be_running_low_on_memory_or_other_resources = 3
This_device_is_not_working_properly_One_of_its_drivers_or_your_registry_might_be_corrupted = 4
The_driver_for_this_device_needs_a_resource_that_Windows_cannot_manage = 5
The_boot_configuration_for_this_device_conflicts_with_other_devices = 6
Cannot_filter = 7
The_driver_loader_for_the_device_is_missing = 8
This_device_is_not_working_properly_because_the_controlling_firmware_is_reporting_the_resources_for_the_device_incorrectly = 9
This_device_cannot_start = 10
This_device_failed = 11
This_device_cannot_find_enough_free_resources_that_it_can_use = 12
Windows_cannot_verify_this_devices_resources = 13
This_device_cannot_work_properly_until_you_restart_your_computer = 14
This_device_is_not_working_properly_because_there_is_probably_a_re_enumeration_problem = 15
Windows_cannot_identify_all_the_resources_this_device_uses = 16
This_device_is_asking_for_an_unknown_resource_type = 17
Reinstall_the_drivers_for_this_device = 18
Failure_using_the_VxD_loader = 19
Your_registry_might_be_corrupted = 20
System_failure_Try_changing_the_driver_for_this_device_If_that_does_not_work_see_your_hardware_documentation_Windows_is_removing_this_device = 21
This_device_is_disabled = 22
System_failure_Try_changing_the_driver_for_this_device_If_that_doesnt_work_see_your_hardware_documentation = 23
This_device_is_not_present_is_not_working_properly_or_does_not_have_all_its_drivers_installed = 24
Windows_is_still_setting_up_this_device1 = 25
Windows_is_still_setting_up_this_device2 = 26
This_device_does_not_have_valid_log_configuration = 27
The_drivers_for_this_device_are_not_installed = 28
This_device_is_disabled_because_the_firmware_of_the_device_did_not_give_it_the_required_resources = 29
This_device_is_using_an_Interrupt_Request_IRQ_resource_that_another_device_is_using = 30
This_device_is_not_working_properly_because_Windows_cannot_load_the_drivers_required_for_this_device = 31
}
Examples
Use $ConfigManagerErrorCode_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "ConfigManagerErrorCode" to friendly text
Note: to use other properties than "ConfigManagerErrorCode", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "ConfigManagerErrorCode"
# to translate other properties, use their translation table instead
$ConfigManagerErrorCode_map = @{
0 = 'This device is working properly.'
1 = 'This device is not configured correctly.'
2 = 'Windows cannot load the driver for this device.'
3 = 'The driver for this device might be corrupted, or your system may be running low on memory or other resources.'
4 = 'This device is not working properly. One of its drivers or your registry might be corrupted.'
5 = 'The driver for this device needs a resource that Windows cannot manage.'
6 = 'The boot configuration for this device conflicts with other devices.'
7 = 'Cannot filter.'
8 = 'The driver loader for the device is missing.'
9 = 'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'
10 = 'This device cannot start.'
11 = 'This device failed.'
12 = 'This device cannot find enough free resources that it can use.'
13 = 'Windows cannot verify this device''s resources.'
14 = 'This device cannot work properly until you restart your computer.'
15 = 'This device is not working properly because there is probably a re-enumeration problem.'
16 = 'Windows cannot identify all the resources this device uses.'
17 = 'This device is asking for an unknown resource type.'
18 = 'Reinstall the drivers for this device.'
19 = 'Failure using the VxD loader.'
20 = 'Your registry might be corrupted.'
21 = 'System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.'
22 = 'This device is disabled.'
23 = 'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'
24 = 'This device is not present, is not working properly, or does not have all its drivers installed.'
25 = 'Windows is still setting up this device.'
26 = 'Windows is still setting up this device.'
27 = 'This device does not have valid log configuration.'
28 = 'The drivers for this device are not installed.'
29 = 'This device is disabled because the firmware of the device did not give it the required resources.'
30 = 'This device is using an Interrupt Request (IRQ) resource that another device is using.'
31 = 'This device is not working properly because Windows cannot load the drivers required for this device.'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ConfigManagerErrorCode", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ConfigManagerErrorCode = @{
Name = 'ConfigManagerErrorCode'
Expression = {
# property is an array, so process all values
$value = $_.ConfigManagerErrorCode
$ConfigManagerErrorCode_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "ConfigManagerErrorCode". The latter
# is defined by the hashtable in $ConfigManagerErrorCode:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $ConfigManagerErrorCode
# ...or dump content of property ConfigManagerErrorCode:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $ConfigManagerErrorCode |
Select-Object -ExpandProperty ConfigManagerErrorCode
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $ConfigManagerErrorCode_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$ConfigManagerErrorCode_map = @{
0 = 'This device is working properly.'
1 = 'This device is not configured correctly.'
2 = 'Windows cannot load the driver for this device.'
3 = 'The driver for this device might be corrupted, or your system may be running low on memory or other resources.'
4 = 'This device is not working properly. One of its drivers or your registry might be corrupted.'
5 = 'The driver for this device needs a resource that Windows cannot manage.'
6 = 'The boot configuration for this device conflicts with other devices.'
7 = 'Cannot filter.'
8 = 'The driver loader for the device is missing.'
9 = 'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'
10 = 'This device cannot start.'
11 = 'This device failed.'
12 = 'This device cannot find enough free resources that it can use.'
13 = 'Windows cannot verify this device''s resources.'
14 = 'This device cannot work properly until you restart your computer.'
15 = 'This device is not working properly because there is probably a re-enumeration problem.'
16 = 'Windows cannot identify all the resources this device uses.'
17 = 'This device is asking for an unknown resource type.'
18 = 'Reinstall the drivers for this device.'
19 = 'Failure using the VxD loader.'
20 = 'Your registry might be corrupted.'
21 = 'System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.'
22 = 'This device is disabled.'
23 = 'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'
24 = 'This device is not present, is not working properly, or does not have all its drivers installed.'
25 = 'Windows is still setting up this device.'
26 = 'Windows is still setting up this device.'
27 = 'This device does not have valid log configuration.'
28 = 'The drivers for this device are not installed.'
29 = 'This device is disabled because the firmware of the device did not give it the required resources.'
30 = 'This device is using an Interrupt Request (IRQ) resource that another device is using.'
31 = 'This device is not working properly because Windows cannot load the drivers required for this device.'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.ConfigManagerErrorCode
# translate raw value to friendly text:
$friendlyName = $ConfigManagerErrorCode_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "ConfigManagerErrorCode" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "ConfigManagerErrorCode", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ConfigManagerErrorCode", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ConfigManagerErrorCode = @{
Name = 'ConfigManagerErrorCode'
Expression = {
# property is an array, so process all values
$value = $_.ConfigManagerErrorCode
switch([int]$value)
{
0 {'This device is working properly.'}
1 {'This device is not configured correctly.'}
2 {'Windows cannot load the driver for this device.'}
3 {'The driver for this device might be corrupted, or your system may be running low on memory or other resources.'}
4 {'This device is not working properly. One of its drivers or your registry might be corrupted.'}
5 {'The driver for this device needs a resource that Windows cannot manage.'}
6 {'The boot configuration for this device conflicts with other devices.'}
7 {'Cannot filter.'}
8 {'The driver loader for the device is missing.'}
9 {'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'}
10 {'This device cannot start.'}
11 {'This device failed.'}
12 {'This device cannot find enough free resources that it can use.'}
13 {'Windows cannot verify this device''s resources.'}
14 {'This device cannot work properly until you restart your computer.'}
15 {'This device is not working properly because there is probably a re-enumeration problem.'}
16 {'Windows cannot identify all the resources this device uses.'}
17 {'This device is asking for an unknown resource type.'}
18 {'Reinstall the drivers for this device.'}
19 {'Failure using the VxD loader.'}
20 {'Your registry might be corrupted.'}
21 {'System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.'}
22 {'This device is disabled.'}
23 {'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'}
24 {'This device is not present, is not working properly, or does not have all its drivers installed.'}
25 {'Windows is still setting up this device.'}
26 {'Windows is still setting up this device.'}
27 {'This device does not have valid log configuration.'}
28 {'The drivers for this device are not installed.'}
29 {'This device is disabled because the firmware of the device did not give it the required resources.'}
30 {'This device is using an Interrupt Request (IRQ) resource that another device is using.'}
31 {'This device is not working properly because Windows cannot load the drivers required for this device.'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "ConfigManagerErrorCode". The latter is defined
# by the hashtable in $ConfigManagerErrorCode:
Select-Object -Property Caption, $ConfigManagerErrorCode
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumConfigManagerErrorCode
{
This_device_is_working_properly = 0
This_device_is_not_configured_correctly = 1
Windows_cannot_load_the_driver_for_this_device = 2
The_driver_for_this_device_might_be_corrupted_or_your_system_may_be_running_low_on_memory_or_other_resources = 3
This_device_is_not_working_properly_One_of_its_drivers_or_your_registry_might_be_corrupted = 4
The_driver_for_this_device_needs_a_resource_that_Windows_cannot_manage = 5
The_boot_configuration_for_this_device_conflicts_with_other_devices = 6
Cannot_filter = 7
The_driver_loader_for_the_device_is_missing = 8
This_device_is_not_working_properly_because_the_controlling_firmware_is_reporting_the_resources_for_the_device_incorrectly = 9
This_device_cannot_start = 10
This_device_failed = 11
This_device_cannot_find_enough_free_resources_that_it_can_use = 12
Windows_cannot_verify_this_devices_resources = 13
This_device_cannot_work_properly_until_you_restart_your_computer = 14
This_device_is_not_working_properly_because_there_is_probably_a_re_enumeration_problem = 15
Windows_cannot_identify_all_the_resources_this_device_uses = 16
This_device_is_asking_for_an_unknown_resource_type = 17
Reinstall_the_drivers_for_this_device = 18
Failure_using_the_VxD_loader = 19
Your_registry_might_be_corrupted = 20
System_failure_Try_changing_the_driver_for_this_device_If_that_does_not_work_see_your_hardware_documentation_Windows_is_removing_this_device = 21
This_device_is_disabled = 22
System_failure_Try_changing_the_driver_for_this_device_If_that_doesnt_work_see_your_hardware_documentation = 23
This_device_is_not_present_is_not_working_properly_or_does_not_have_all_its_drivers_installed = 24
Windows_is_still_setting_up_this_device1 = 25
Windows_is_still_setting_up_this_device2 = 26
This_device_does_not_have_valid_log_configuration = 27
The_drivers_for_this_device_are_not_installed = 28
This_device_is_disabled_because_the_firmware_of_the_device_did_not_give_it_the_required_resources = 29
This_device_is_using_an_Interrupt_Request_IRQ_resource_that_another_device_is_using = 30
This_device_is_not_working_properly_because_Windows_cannot_load_the_drivers_required_for_this_device = 31
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.ConfigManagerErrorCode
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **ConfigManagerErrorCode**
[EnumConfigManagerErrorCode]$rawValue
# get a comma-separated string:
[EnumConfigManagerErrorCode]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumConfigManagerErrorCode]
#endregion
Enums must cover all possible values. If ConfigManagerErrorCode returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
ConfigManagerUserConfig
If True, the device is using a user-defined configuration.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, ConfigManagerUserConfig
CorrectableError
If True, the most recent error was correctable. If the ErrorInfo property is equal to 3 (OK), then this property has no meaning.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, CorrectableError
CreationClassName
Name of the first concrete class to appear in the inheritance chain used in the creation of an instance. When used with the other key properties of the class, the property allows all instances of this class and its subclasses to be uniquely identified.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, CreationClassName
CurrentSRAM
Array of types of Static Random Access Memory (SRAM) being used for the cache memory.
This value comes from the Current SRAM Type member of the Cache Information structure in the SMBIOS information.
CurrentSRAM returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$CurrentSRAM_map = @{
0 = 'Other'
1 = 'Unknown'
2 = 'Non-Burst'
3 = 'Burst'
4 = 'Pipeline Burst'
5 = 'Synchronous'
6 = 'Asynchronous'
}
Use a switch statement
switch([int]$value)
{
0 {'Other'}
1 {'Unknown'}
2 {'Non-Burst'}
3 {'Burst'}
4 {'Pipeline Burst'}
5 {'Synchronous'}
6 {'Asynchronous'}
default {"$value"}
}
Use Enum structure
Enum EnumCurrentSRAM
{
Other = 0
Unknown = 1
Non_Burst = 2
Burst = 3
Pipeline_Burst = 4
Synchronous = 5
Asynchronous = 6
}
Examples
Use $CurrentSRAM_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "CurrentSRAM" to friendly text
Note: to use other properties than "CurrentSRAM", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "CurrentSRAM"
# to translate other properties, use their translation table instead
$CurrentSRAM_map = @{
0 = 'Other'
1 = 'Unknown'
2 = 'Non-Burst'
3 = 'Burst'
4 = 'Pipeline Burst'
5 = 'Synchronous'
6 = 'Asynchronous'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "CurrentSRAM", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$CurrentSRAM = @{
Name = 'CurrentSRAM'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.CurrentSRAM)
{
# important: convert original value to [int] because
# hashtable keys are type-aware:
$CurrentSRAM_map[[int]$value]
}
# uncomment to get a comma-separated string instead
# of a string array:
$result <#-join ', '#>
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "CurrentSRAM". The latter
# is defined by the hashtable in $CurrentSRAM:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $CurrentSRAM
# ...or dump content of property CurrentSRAM:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $CurrentSRAM |
Select-Object -ExpandProperty CurrentSRAM
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $CurrentSRAM_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when there
is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$CurrentSRAM_map = @{
0 = 'Other'
1 = 'Unknown'
2 = 'Non-Burst'
3 = 'Burst'
4 = 'Pipeline Burst'
5 = 'Synchronous'
6 = 'Asynchronous'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property (hint: the property is an array!)
$rawValues = $instance.CurrentSRAM
# translate all raw values into friendly names:
$friendlyNames = foreach($rawValue in $rawValues)
{ $CurrentSRAM_map[[int]$rawValue] }
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "CurrentSRAM" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "CurrentSRAM", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "CurrentSRAM", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$CurrentSRAM = @{
Name = 'CurrentSRAM'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.CurrentSRAM)
{
switch([int]$value)
{
0 {'Other'}
1 {'Unknown'}
2 {'Non-Burst'}
3 {'Burst'}
4 {'Pipeline Burst'}
5 {'Synchronous'}
6 {'Asynchronous'}
default {"$value"}
}
}
$result
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "CurrentSRAM". The latter is defined
# by the hashtable in $CurrentSRAM:
Select-Object -Property Caption, $CurrentSRAM
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumCurrentSRAM
{
Other = 0
Unknown = 1
Non_Burst = 2
Burst = 3
Pipeline_Burst = 4
Synchronous = 5
Asynchronous = 6
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.CurrentSRAM
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **CurrentSRAM**
[EnumCurrentSRAM[]]$rawValue
# get a comma-separated string:
[EnumCurrentSRAM[]]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumCurrentSRAM[]]
#endregion
Enums must cover all possible values. If CurrentSRAM returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
Description
Description of the object.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, Description
DeviceID
Unique identifier of the cache represented by an instance of Win32_CacheMemory.
Example: “Cache Memory 1”
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID
EndingAddress
Ending address, referenced by an application or operating system and mapped by a memory controller, for this memory object. The ending address is specified in kilobytes.
For more information about using uint64 values in scripts, see Scripting in WMI.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, EndingAddress
ErrorAccess
Memory access operation that caused the last error. The type of error is described by the ErrorInfo property. If ErrorInfo is equal to 3 (OK), then this property has no meaning.
ErrorAccess returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$ErrorAccess_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Read'
4 = 'Write'
5 = 'Partial Write'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Read'}
4 {'Write'}
5 {'Partial Write'}
default {"$value"}
}
Use Enum structure
Enum EnumErrorAccess
{
Other = 1
Unknown = 2
Read = 3
Write = 4
Partial_Write = 5
}
Examples
Use $ErrorAccess_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "ErrorAccess" to friendly text
Note: to use other properties than "ErrorAccess", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "ErrorAccess"
# to translate other properties, use their translation table instead
$ErrorAccess_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Read'
4 = 'Write'
5 = 'Partial Write'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ErrorAccess", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ErrorAccess = @{
Name = 'ErrorAccess'
Expression = {
# property is an array, so process all values
$value = $_.ErrorAccess
$ErrorAccess_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "ErrorAccess". The latter
# is defined by the hashtable in $ErrorAccess:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $ErrorAccess
# ...or dump content of property ErrorAccess:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $ErrorAccess |
Select-Object -ExpandProperty ErrorAccess
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $ErrorAccess_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$ErrorAccess_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Read'
4 = 'Write'
5 = 'Partial Write'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.ErrorAccess
# translate raw value to friendly text:
$friendlyName = $ErrorAccess_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "ErrorAccess" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "ErrorAccess", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ErrorAccess", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ErrorAccess = @{
Name = 'ErrorAccess'
Expression = {
# property is an array, so process all values
$value = $_.ErrorAccess
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Read'}
4 {'Write'}
5 {'Partial Write'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "ErrorAccess". The latter is defined
# by the hashtable in $ErrorAccess:
Select-Object -Property Caption, $ErrorAccess
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumErrorAccess
{
Other = 1
Unknown = 2
Read = 3
Write = 4
Partial_Write = 5
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.ErrorAccess
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **ErrorAccess**
[EnumErrorAccess]$rawValue
# get a comma-separated string:
[EnumErrorAccess]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumErrorAccess]
#endregion
Enums must cover all possible values. If ErrorAccess returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
ErrorAddress
Address of the last memory error. The type of error is described by the ErrorInfo property. If ErrorInfo is equal to 3 (OK), then this property has no meaning.
For more information about using uint64 values in scripts, see Scripting in WMI.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, ErrorAddress
ErrorCleared
If True, the error reported in LastErrorCode is now cleared.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, ErrorCleared
ErrorCorrectType
Error correction method used by the cache memory.
This value comes from the Error Correction Type member of the Cache Information structure in the SMBIOS information.
ErrorCorrectType returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$ErrorCorrectType_map = @{
0 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'None'
4 = 'Parity'
5 = 'Single-bit ECC'
6 = 'Multi-bit ECC'
}
Use a switch statement
switch([int]$value)
{
0 {'Reserved'}
1 {'Other'}
2 {'Unknown'}
3 {'None'}
4 {'Parity'}
5 {'Single-bit ECC'}
6 {'Multi-bit ECC'}
default {"$value"}
}
Use Enum structure
Enum EnumErrorCorrectType
{
Reserved = 0
Other = 1
Unknown = 2
None = 3
Parity = 4
Single_bit_ECC = 5
Multi_bit_ECC = 6
}
Examples
Use $ErrorCorrectType_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "ErrorCorrectType" to friendly text
Note: to use other properties than "ErrorCorrectType", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "ErrorCorrectType"
# to translate other properties, use their translation table instead
$ErrorCorrectType_map = @{
0 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'None'
4 = 'Parity'
5 = 'Single-bit ECC'
6 = 'Multi-bit ECC'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ErrorCorrectType", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ErrorCorrectType = @{
Name = 'ErrorCorrectType'
Expression = {
# property is an array, so process all values
$value = $_.ErrorCorrectType
$ErrorCorrectType_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "ErrorCorrectType". The latter
# is defined by the hashtable in $ErrorCorrectType:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $ErrorCorrectType
# ...or dump content of property ErrorCorrectType:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $ErrorCorrectType |
Select-Object -ExpandProperty ErrorCorrectType
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $ErrorCorrectType_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$ErrorCorrectType_map = @{
0 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'None'
4 = 'Parity'
5 = 'Single-bit ECC'
6 = 'Multi-bit ECC'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.ErrorCorrectType
# translate raw value to friendly text:
$friendlyName = $ErrorCorrectType_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "ErrorCorrectType" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "ErrorCorrectType", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ErrorCorrectType", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ErrorCorrectType = @{
Name = 'ErrorCorrectType'
Expression = {
# property is an array, so process all values
$value = $_.ErrorCorrectType
switch([int]$value)
{
0 {'Reserved'}
1 {'Other'}
2 {'Unknown'}
3 {'None'}
4 {'Parity'}
5 {'Single-bit ECC'}
6 {'Multi-bit ECC'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "ErrorCorrectType". The latter is defined
# by the hashtable in $ErrorCorrectType:
Select-Object -Property Caption, $ErrorCorrectType
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumErrorCorrectType
{
Reserved = 0
Other = 1
Unknown = 2
None = 3
Parity = 4
Single_bit_ECC = 5
Multi_bit_ECC = 6
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.ErrorCorrectType
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **ErrorCorrectType**
[EnumErrorCorrectType]$rawValue
# get a comma-separated string:
[EnumErrorCorrectType]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumErrorCorrectType]
#endregion
Enums must cover all possible values. If ErrorCorrectType returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
ErrorData
Array of data captured during the last erroneous memory access. The data occupies the first n octets of the array necessary to hold the number of bits specified by the ErrorTransferSize property. If ErrorTransferSize is 0 (zero), then this property has no meaning.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, ErrorData
ErrorDataOrder
Ordering for data stored in the ErrorData property. If ErrorTransferSize is 0 (zero), then this property has no meaning.
ErrorDataOrder returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$ErrorDataOrder_map = @{
0 = 'Unknown'
1 = 'Least Significant Byte First'
2 = 'Most Significant Byte First'
}
Use a switch statement
switch([int]$value)
{
0 {'Unknown'}
1 {'Least Significant Byte First'}
2 {'Most Significant Byte First'}
default {"$value"}
}
Use Enum structure
Enum EnumErrorDataOrder
{
Unknown = 0
Least_Significant_Byte_First = 1
Most_Significant_Byte_First = 2
}
Examples
Use $ErrorDataOrder_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "ErrorDataOrder" to friendly text
Note: to use other properties than "ErrorDataOrder", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "ErrorDataOrder"
# to translate other properties, use their translation table instead
$ErrorDataOrder_map = @{
0 = 'Unknown'
1 = 'Least Significant Byte First'
2 = 'Most Significant Byte First'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ErrorDataOrder", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ErrorDataOrder = @{
Name = 'ErrorDataOrder'
Expression = {
# property is an array, so process all values
$value = $_.ErrorDataOrder
$ErrorDataOrder_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "ErrorDataOrder". The latter
# is defined by the hashtable in $ErrorDataOrder:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $ErrorDataOrder
# ...or dump content of property ErrorDataOrder:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $ErrorDataOrder |
Select-Object -ExpandProperty ErrorDataOrder
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $ErrorDataOrder_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$ErrorDataOrder_map = @{
0 = 'Unknown'
1 = 'Least Significant Byte First'
2 = 'Most Significant Byte First'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.ErrorDataOrder
# translate raw value to friendly text:
$friendlyName = $ErrorDataOrder_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "ErrorDataOrder" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "ErrorDataOrder", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ErrorDataOrder", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ErrorDataOrder = @{
Name = 'ErrorDataOrder'
Expression = {
# property is an array, so process all values
$value = $_.ErrorDataOrder
switch([int]$value)
{
0 {'Unknown'}
1 {'Least Significant Byte First'}
2 {'Most Significant Byte First'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "ErrorDataOrder". The latter is defined
# by the hashtable in $ErrorDataOrder:
Select-Object -Property Caption, $ErrorDataOrder
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumErrorDataOrder
{
Unknown = 0
Least_Significant_Byte_First = 1
Most_Significant_Byte_First = 2
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.ErrorDataOrder
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **ErrorDataOrder**
[EnumErrorDataOrder]$rawValue
# get a comma-separated string:
[EnumErrorDataOrder]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumErrorDataOrder]
#endregion
Enums must cover all possible values. If ErrorDataOrder returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
ErrorDescription
More information about the error recorded in LastErrorCode, and information on any corrective actions that may be taken.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, ErrorDescription
ErrorInfo
Type of error that occurred most recently. The values 12-14 are undefined in the CIM schema because in DMI they mix the semantics of the type of error and whether it was correctable or not. The latter is indicated in the property CorrectableError.
ErrorInfo returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$ErrorInfo_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'OK'
4 = 'Bad Read'
5 = 'Parity Error'
6 = 'Single-Bit Error'
7 = 'Double-Bit Error'
8 = 'Multi-Bit Error'
9 = 'Nibble Error'
10 = 'Checksum Error'
11 = 'CRC Error'
12 = 'Undefined'
13 = 'Undefined'
14 = 'Undefined'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'OK'}
4 {'Bad Read'}
5 {'Parity Error'}
6 {'Single-Bit Error'}
7 {'Double-Bit Error'}
8 {'Multi-Bit Error'}
9 {'Nibble Error'}
10 {'Checksum Error'}
11 {'CRC Error'}
12 {'Undefined'}
13 {'Undefined'}
14 {'Undefined'}
default {"$value"}
}
Use Enum structure
Enum EnumErrorInfo
{
Other = 1
Unknown = 2
OK = 3
Bad_Read = 4
Parity_Error = 5
Single_Bit_Error = 6
Double_Bit_Error = 7
Multi_Bit_Error = 8
Nibble_Error = 9
Checksum_Error = 10
CRC_Error = 11
Undefined1 = 12
Undefined2 = 13
Undefined3 = 14
}
Examples
Use $ErrorInfo_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "ErrorInfo" to friendly text
Note: to use other properties than "ErrorInfo", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "ErrorInfo"
# to translate other properties, use their translation table instead
$ErrorInfo_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'OK'
4 = 'Bad Read'
5 = 'Parity Error'
6 = 'Single-Bit Error'
7 = 'Double-Bit Error'
8 = 'Multi-Bit Error'
9 = 'Nibble Error'
10 = 'Checksum Error'
11 = 'CRC Error'
12 = 'Undefined'
13 = 'Undefined'
14 = 'Undefined'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ErrorInfo", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ErrorInfo = @{
Name = 'ErrorInfo'
Expression = {
# property is an array, so process all values
$value = $_.ErrorInfo
$ErrorInfo_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "ErrorInfo". The latter
# is defined by the hashtable in $ErrorInfo:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $ErrorInfo
# ...or dump content of property ErrorInfo:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $ErrorInfo |
Select-Object -ExpandProperty ErrorInfo
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $ErrorInfo_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$ErrorInfo_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'OK'
4 = 'Bad Read'
5 = 'Parity Error'
6 = 'Single-Bit Error'
7 = 'Double-Bit Error'
8 = 'Multi-Bit Error'
9 = 'Nibble Error'
10 = 'Checksum Error'
11 = 'CRC Error'
12 = 'Undefined'
13 = 'Undefined'
14 = 'Undefined'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.ErrorInfo
# translate raw value to friendly text:
$friendlyName = $ErrorInfo_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "ErrorInfo" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "ErrorInfo", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ErrorInfo", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ErrorInfo = @{
Name = 'ErrorInfo'
Expression = {
# property is an array, so process all values
$value = $_.ErrorInfo
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'OK'}
4 {'Bad Read'}
5 {'Parity Error'}
6 {'Single-Bit Error'}
7 {'Double-Bit Error'}
8 {'Multi-Bit Error'}
9 {'Nibble Error'}
10 {'Checksum Error'}
11 {'CRC Error'}
12 {'Undefined'}
13 {'Undefined'}
14 {'Undefined'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "ErrorInfo". The latter is defined
# by the hashtable in $ErrorInfo:
Select-Object -Property Caption, $ErrorInfo
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumErrorInfo
{
Other = 1
Unknown = 2
OK = 3
Bad_Read = 4
Parity_Error = 5
Single_Bit_Error = 6
Double_Bit_Error = 7
Multi_Bit_Error = 8
Nibble_Error = 9
Checksum_Error = 10
CRC_Error = 11
Undefined1 = 12
Undefined2 = 13
Undefined3 = 14
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.ErrorInfo
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **ErrorInfo**
[EnumErrorInfo]$rawValue
# get a comma-separated string:
[EnumErrorInfo]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumErrorInfo]
#endregion
Enums must cover all possible values. If ErrorInfo returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
ErrorMethodology
Details on the parity or CRC algorithms, ECC, or other mechanisms used.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, ErrorMethodology
ErrorResolution
Range, in bytes, to which the last error can be resolved. For example, if error addresses are resolved to bit 11 (that is, on a typical page basis), then errors can be resolved to 4 KB boundaries and this property is set to 4000. If the ErrorInfo property is equal to 3 (OK), then this property has no meaning.
For more information about using uint64 values in scripts, see Scripting in WMI.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, ErrorResolution
ErrorTime
Time that the last memory error occurred. The type of error is described by the ErrorInfo property. If the ErrorInfo property is equal to 3 (OK), then this property has no meaning.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, ErrorTime
ErrorTransferSize
Size of the data transfer in bits that caused the last error. 0 (zero) indicates no error. If the ErrorInfo property is equal to 3 (OK), then this property should be set to 0 (zero).
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, ErrorTransferSize
FlushTimer
Maximum amount of time, in seconds, dirty lines or buckets may remain in the cache before they are flushed. A value of 0 (zero) indicates that a cache flush is not controlled by a flushing timer.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, FlushTimer
InstallDate
Date and time the object was installed. This property does not need a value to indicate that the object is installed.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, InstallDate
InstalledSize
Current size of the installed cache memory.
This value comes from the Installed Size member of the Cache Information structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, InstalledSize
LastErrorCode
Last error code reported by the logical device.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, LastErrorCode
Level
Level of the cache.
This value comes from the Cache Configuration member of the Cache Information structure in the SMBIOS information.
Level returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$Level_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Primary'
4 = 'Secondary'
5 = 'Tertiary'
6 = 'Not Applicable'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Primary'}
4 {'Secondary'}
5 {'Tertiary'}
6 {'Not Applicable'}
default {"$value"}
}
Use Enum structure
Enum EnumLevel
{
Other = 1
Unknown = 2
Primary = 3
Secondary = 4
Tertiary = 5
Not_Applicable = 6
}
Examples
Use $Level_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "Level" to friendly text
Note: to use other properties than "Level", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Level"
# to translate other properties, use their translation table instead
$Level_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Primary'
4 = 'Secondary'
5 = 'Tertiary'
6 = 'Not Applicable'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Level", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Level = @{
Name = 'Level'
Expression = {
# property is an array, so process all values
$value = $_.Level
$Level_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "Level". The latter
# is defined by the hashtable in $Level:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $Level
# ...or dump content of property Level:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $Level |
Select-Object -ExpandProperty Level
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $Level_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$Level_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Primary'
4 = 'Secondary'
5 = 'Tertiary'
6 = 'Not Applicable'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.Level
# translate raw value to friendly text:
$friendlyName = $Level_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "Level" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "Level", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Level", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Level = @{
Name = 'Level'
Expression = {
# property is an array, so process all values
$value = $_.Level
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Primary'}
4 {'Secondary'}
5 {'Tertiary'}
6 {'Not Applicable'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "Level". The latter is defined
# by the hashtable in $Level:
Select-Object -Property Caption, $Level
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumLevel
{
Other = 1
Unknown = 2
Primary = 3
Secondary = 4
Tertiary = 5
Not_Applicable = 6
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.Level
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **Level**
[EnumLevel]$rawValue
# get a comma-separated string:
[EnumLevel]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumLevel]
#endregion
Enums must cover all possible values. If Level returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
LineSize
Size, in bytes, of a single cache bucket or line.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, LineSize
Location
Physical location of the cache memory.
This value comes from the Cache Configuration member of the Cache Information structure in the SMBIOS information.
Location returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$Location_map = @{
0 = 'Internal'
1 = 'External'
2 = 'Reserved'
3 = 'Unknown'
}
Use a switch statement
switch([int]$value)
{
0 {'Internal'}
1 {'External'}
2 {'Reserved'}
3 {'Unknown'}
default {"$value"}
}
Use Enum structure
Enum EnumLocation
{
Internal = 0
External = 1
Reserved = 2
Unknown = 3
}
Examples
Use $Location_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "Location" to friendly text
Note: to use other properties than "Location", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Location"
# to translate other properties, use their translation table instead
$Location_map = @{
0 = 'Internal'
1 = 'External'
2 = 'Reserved'
3 = 'Unknown'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Location", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Location = @{
Name = 'Location'
Expression = {
# property is an array, so process all values
$value = $_.Location
$Location_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "Location". The latter
# is defined by the hashtable in $Location:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $Location
# ...or dump content of property Location:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $Location |
Select-Object -ExpandProperty Location
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $Location_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$Location_map = @{
0 = 'Internal'
1 = 'External'
2 = 'Reserved'
3 = 'Unknown'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.Location
# translate raw value to friendly text:
$friendlyName = $Location_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "Location" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "Location", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Location", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Location = @{
Name = 'Location'
Expression = {
# property is an array, so process all values
$value = $_.Location
switch([int]$value)
{
0 {'Internal'}
1 {'External'}
2 {'Reserved'}
3 {'Unknown'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "Location". The latter is defined
# by the hashtable in $Location:
Select-Object -Property Caption, $Location
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumLocation
{
Internal = 0
External = 1
Reserved = 2
Unknown = 3
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.Location
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **Location**
[EnumLocation]$rawValue
# get a comma-separated string:
[EnumLocation]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumLocation]
#endregion
Enums must cover all possible values. If Location returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
MaxCacheSize
Maximum cache size installable to this particular cache memory.
This value comes from the Maximum Cache Size member of the Cache Information structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, MaxCacheSize
Name
Label by which the object is known. When subclassed, the property can be overridden to be a key property.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, Name
NumberOfBlocks
Total number of consecutive blocks, each block the size of the value contained in the BlockSize property, which form this storage extent. Total size of the storage extent can be calculated by multiplying the value of the BlockSize property by the value of this property. If the value of BlockSize is 1, this property is the total size of the storage extent.
For more information about using uint64 values in scripts, see Scripting in WMI.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, NumberOfBlocks
OtherErrorDescription
Free-form string providing more information if the ErrorType property is set to 1, Other. Otherwise, this string has no meaning.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, OtherErrorDescription
PNPDeviceID
Windows Plug and Play device identifier of the logical device.
Example: “*PNP030b”
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, PNPDeviceID
PowerManagementCapabilities
Array of the specific power-related capabilities of a logical device.
PowerManagementCapabilities returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$PowerManagementCapabilities_map = @{
0 = 'Unknown'
1 = 'Not Supported'
2 = 'Disabled'
3 = 'Enabled'
4 = 'Power Saving Modes Entered Automatically'
5 = 'Power State Settable'
6 = 'Power Cycling Supported'
7 = 'Timed Power On Supported'
}
Use a switch statement
switch([int]$value)
{
0 {'Unknown'}
1 {'Not Supported'}
2 {'Disabled'}
3 {'Enabled'}
4 {'Power Saving Modes Entered Automatically'}
5 {'Power State Settable'}
6 {'Power Cycling Supported'}
7 {'Timed Power On Supported'}
default {"$value"}
}
Use Enum structure
Enum EnumPowerManagementCapabilities
{
Unknown = 0
Not_Supported = 1
Disabled = 2
Enabled = 3
Power_Saving_Modes_Entered_Automatically = 4
Power_State_Settable = 5
Power_Cycling_Supported = 6
Timed_Power_On_Supported = 7
}
Examples
Use $PowerManagementCapabilities_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "PowerManagementCapabilities" to friendly text
Note: to use other properties than "PowerManagementCapabilities", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "PowerManagementCapabilities"
# to translate other properties, use their translation table instead
$PowerManagementCapabilities_map = @{
0 = 'Unknown'
1 = 'Not Supported'
2 = 'Disabled'
3 = 'Enabled'
4 = 'Power Saving Modes Entered Automatically'
5 = 'Power State Settable'
6 = 'Power Cycling Supported'
7 = 'Timed Power On Supported'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "PowerManagementCapabilities", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$PowerManagementCapabilities = @{
Name = 'PowerManagementCapabilities'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.PowerManagementCapabilities)
{
# important: convert original value to [int] because
# hashtable keys are type-aware:
$PowerManagementCapabilities_map[[int]$value]
}
# uncomment to get a comma-separated string instead
# of a string array:
$result <#-join ', '#>
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "PowerManagementCapabilities". The latter
# is defined by the hashtable in $PowerManagementCapabilities:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $PowerManagementCapabilities
# ...or dump content of property PowerManagementCapabilities:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $PowerManagementCapabilities |
Select-Object -ExpandProperty PowerManagementCapabilities
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $PowerManagementCapabilities_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when there
is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$PowerManagementCapabilities_map = @{
0 = 'Unknown'
1 = 'Not Supported'
2 = 'Disabled'
3 = 'Enabled'
4 = 'Power Saving Modes Entered Automatically'
5 = 'Power State Settable'
6 = 'Power Cycling Supported'
7 = 'Timed Power On Supported'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property (hint: the property is an array!)
$rawValues = $instance.PowerManagementCapabilities
# translate all raw values into friendly names:
$friendlyNames = foreach($rawValue in $rawValues)
{ $PowerManagementCapabilities_map[[int]$rawValue] }
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "PowerManagementCapabilities" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "PowerManagementCapabilities", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "PowerManagementCapabilities", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$PowerManagementCapabilities = @{
Name = 'PowerManagementCapabilities'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.PowerManagementCapabilities)
{
switch([int]$value)
{
0 {'Unknown'}
1 {'Not Supported'}
2 {'Disabled'}
3 {'Enabled'}
4 {'Power Saving Modes Entered Automatically'}
5 {'Power State Settable'}
6 {'Power Cycling Supported'}
7 {'Timed Power On Supported'}
default {"$value"}
}
}
$result
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "PowerManagementCapabilities". The latter is defined
# by the hashtable in $PowerManagementCapabilities:
Select-Object -Property Caption, $PowerManagementCapabilities
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumPowerManagementCapabilities
{
Unknown = 0
Not_Supported = 1
Disabled = 2
Enabled = 3
Power_Saving_Modes_Entered_Automatically = 4
Power_State_Settable = 5
Power_Cycling_Supported = 6
Timed_Power_On_Supported = 7
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.PowerManagementCapabilities
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **PowerManagementCapabilities**
[EnumPowerManagementCapabilities[]]$rawValue
# get a comma-separated string:
[EnumPowerManagementCapabilities[]]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumPowerManagementCapabilities[]]
#endregion
Enums must cover all possible values. If PowerManagementCapabilities returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
PowerManagementSupported
If True, the device can be power-managed (can be put into suspend mode, and so on). The property does not indicate that power management features are currently enabled, only that the logical device is capable of power management.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, PowerManagementSupported
Purpose
Free-form string describing the media and its use.
This value comes from the Socket Designation member of the Cache Information structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, Purpose
ReadPolicy
Policy that shall be employed by the cache for handling read requests.
ReadPolicy returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$ReadPolicy_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Read'
4 = 'Read-Ahead'
5 = 'Read and Read-Ahead'
6 = 'Determination Per I/O'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Read'}
4 {'Read-Ahead'}
5 {'Read and Read-Ahead'}
6 {'Determination Per I/O'}
default {"$value"}
}
Use Enum structure
Enum EnumReadPolicy
{
Other = 1
Unknown = 2
Read = 3
Read_Ahead = 4
Read_and_Read_Ahead = 5
Determination_Per_IO = 6
}
Examples
Use $ReadPolicy_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "ReadPolicy" to friendly text
Note: to use other properties than "ReadPolicy", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "ReadPolicy"
# to translate other properties, use their translation table instead
$ReadPolicy_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Read'
4 = 'Read-Ahead'
5 = 'Read and Read-Ahead'
6 = 'Determination Per I/O'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ReadPolicy", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ReadPolicy = @{
Name = 'ReadPolicy'
Expression = {
# property is an array, so process all values
$value = $_.ReadPolicy
$ReadPolicy_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "ReadPolicy". The latter
# is defined by the hashtable in $ReadPolicy:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $ReadPolicy
# ...or dump content of property ReadPolicy:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $ReadPolicy |
Select-Object -ExpandProperty ReadPolicy
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $ReadPolicy_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$ReadPolicy_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Read'
4 = 'Read-Ahead'
5 = 'Read and Read-Ahead'
6 = 'Determination Per I/O'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.ReadPolicy
# translate raw value to friendly text:
$friendlyName = $ReadPolicy_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "ReadPolicy" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "ReadPolicy", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ReadPolicy", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ReadPolicy = @{
Name = 'ReadPolicy'
Expression = {
# property is an array, so process all values
$value = $_.ReadPolicy
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Read'}
4 {'Read-Ahead'}
5 {'Read and Read-Ahead'}
6 {'Determination Per I/O'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "ReadPolicy". The latter is defined
# by the hashtable in $ReadPolicy:
Select-Object -Property Caption, $ReadPolicy
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumReadPolicy
{
Other = 1
Unknown = 2
Read = 3
Read_Ahead = 4
Read_and_Read_Ahead = 5
Determination_Per_IO = 6
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.ReadPolicy
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **ReadPolicy**
[EnumReadPolicy]$rawValue
# get a comma-separated string:
[EnumReadPolicy]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumReadPolicy]
#endregion
Enums must cover all possible values. If ReadPolicy returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
ReplacementPolicy
Algorithm to determine which cache lines or buckets should be reused.
ReplacementPolicy returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$ReplacementPolicy_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Least Recently Used (LRU)'
4 = 'First In First Out (FIFO)'
5 = 'Last In First Out (LIFO)'
6 = 'Least Frequently Used (LFU)'
7 = 'Most Frequently Used (MFU)'
8 = 'Data Dependent Multiple Algorithms'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Least Recently Used (LRU)'}
4 {'First In First Out (FIFO)'}
5 {'Last In First Out (LIFO)'}
6 {'Least Frequently Used (LFU)'}
7 {'Most Frequently Used (MFU)'}
8 {'Data Dependent Multiple Algorithms'}
default {"$value"}
}
Use Enum structure
Enum EnumReplacementPolicy
{
Other = 1
Unknown = 2
Least_Recently_Used_LRU = 3
First_In_First_Out_FIFO = 4
Last_In_First_Out_LIFO = 5
Least_Frequently_Used_LFU = 6
Most_Frequently_Used_MFU = 7
Data_Dependent_Multiple_Algorithms = 8
}
Examples
Use $ReplacementPolicy_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "ReplacementPolicy" to friendly text
Note: to use other properties than "ReplacementPolicy", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "ReplacementPolicy"
# to translate other properties, use their translation table instead
$ReplacementPolicy_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Least Recently Used (LRU)'
4 = 'First In First Out (FIFO)'
5 = 'Last In First Out (LIFO)'
6 = 'Least Frequently Used (LFU)'
7 = 'Most Frequently Used (MFU)'
8 = 'Data Dependent Multiple Algorithms'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ReplacementPolicy", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ReplacementPolicy = @{
Name = 'ReplacementPolicy'
Expression = {
# property is an array, so process all values
$value = $_.ReplacementPolicy
$ReplacementPolicy_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "ReplacementPolicy". The latter
# is defined by the hashtable in $ReplacementPolicy:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $ReplacementPolicy
# ...or dump content of property ReplacementPolicy:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $ReplacementPolicy |
Select-Object -ExpandProperty ReplacementPolicy
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $ReplacementPolicy_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$ReplacementPolicy_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Least Recently Used (LRU)'
4 = 'First In First Out (FIFO)'
5 = 'Last In First Out (LIFO)'
6 = 'Least Frequently Used (LFU)'
7 = 'Most Frequently Used (MFU)'
8 = 'Data Dependent Multiple Algorithms'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.ReplacementPolicy
# translate raw value to friendly text:
$friendlyName = $ReplacementPolicy_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "ReplacementPolicy" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "ReplacementPolicy", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ReplacementPolicy", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ReplacementPolicy = @{
Name = 'ReplacementPolicy'
Expression = {
# property is an array, so process all values
$value = $_.ReplacementPolicy
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Least Recently Used (LRU)'}
4 {'First In First Out (FIFO)'}
5 {'Last In First Out (LIFO)'}
6 {'Least Frequently Used (LFU)'}
7 {'Most Frequently Used (MFU)'}
8 {'Data Dependent Multiple Algorithms'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "ReplacementPolicy". The latter is defined
# by the hashtable in $ReplacementPolicy:
Select-Object -Property Caption, $ReplacementPolicy
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumReplacementPolicy
{
Other = 1
Unknown = 2
Least_Recently_Used_LRU = 3
First_In_First_Out_FIFO = 4
Last_In_First_Out_LIFO = 5
Least_Frequently_Used_LFU = 6
Most_Frequently_Used_MFU = 7
Data_Dependent_Multiple_Algorithms = 8
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.ReplacementPolicy
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **ReplacementPolicy**
[EnumReplacementPolicy]$rawValue
# get a comma-separated string:
[EnumReplacementPolicy]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumReplacementPolicy]
#endregion
Enums must cover all possible values. If ReplacementPolicy returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
StartingAddress
Beginning address, referenced by an application or operating system and mapped by a memory controller, for this memory object. The starting address is specified in kilobytes.
For more information about using uint64 values in scripts, see Scripting in WMI.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, StartingAddress
Status
Current status of an object. Various operational and nonoperational statuses can be defined. Available values:
$values = 'Degraded','Error','Lost Comm','No Contact','NonRecover','OK','Pred Fail','Service','Starting','Stopping','Stressed','Unknown'
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, Status
StatusInfo
State of the logical device. If this property does not apply to the logical device, the value 5 (Not Applicable) should be used.
This value comes from the Cache Configuration member of the Cache Information structure in the SMBIOS information.
StatusInfo returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$StatusInfo_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Enabled'
4 = 'Disabled'
5 = 'Not Applicable'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Enabled'}
4 {'Disabled'}
5 {'Not Applicable'}
default {"$value"}
}
Use Enum structure
Enum EnumStatusInfo
{
Other = 1
Unknown = 2
Enabled = 3
Disabled = 4
Not_Applicable = 5
}
Examples
Use $StatusInfo_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "StatusInfo" to friendly text
Note: to use other properties than "StatusInfo", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "StatusInfo"
# to translate other properties, use their translation table instead
$StatusInfo_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Enabled'
4 = 'Disabled'
5 = 'Not Applicable'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "StatusInfo", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$StatusInfo = @{
Name = 'StatusInfo'
Expression = {
# property is an array, so process all values
$value = $_.StatusInfo
$StatusInfo_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "StatusInfo". The latter
# is defined by the hashtable in $StatusInfo:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $StatusInfo
# ...or dump content of property StatusInfo:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $StatusInfo |
Select-Object -ExpandProperty StatusInfo
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $StatusInfo_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$StatusInfo_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Enabled'
4 = 'Disabled'
5 = 'Not Applicable'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.StatusInfo
# translate raw value to friendly text:
$friendlyName = $StatusInfo_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "StatusInfo" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "StatusInfo", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "StatusInfo", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$StatusInfo = @{
Name = 'StatusInfo'
Expression = {
# property is an array, so process all values
$value = $_.StatusInfo
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Enabled'}
4 {'Disabled'}
5 {'Not Applicable'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "StatusInfo". The latter is defined
# by the hashtable in $StatusInfo:
Select-Object -Property Caption, $StatusInfo
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumStatusInfo
{
Other = 1
Unknown = 2
Enabled = 3
Disabled = 4
Not_Applicable = 5
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.StatusInfo
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **StatusInfo**
[EnumStatusInfo]$rawValue
# get a comma-separated string:
[EnumStatusInfo]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumStatusInfo]
#endregion
Enums must cover all possible values. If StatusInfo returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
SupportedSRAM
Array of supported types of Static Random Access Memory (SRAM) that can be used for the cache memory.
This value comes from the Supported SRAM Type member of the Cache Information structure in the SMBIOS information.
SupportedSRAM returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$SupportedSRAM_map = @{
0 = 'Other'
1 = 'Unknown'
2 = 'Non-Burst'
3 = 'Burst'
4 = 'Pipeline Burst'
5 = 'Synchronous'
6 = 'Asynchronous'
}
Use a switch statement
switch([int]$value)
{
0 {'Other'}
1 {'Unknown'}
2 {'Non-Burst'}
3 {'Burst'}
4 {'Pipeline Burst'}
5 {'Synchronous'}
6 {'Asynchronous'}
default {"$value"}
}
Use Enum structure
Enum EnumSupportedSRAM
{
Other = 0
Unknown = 1
Non_Burst = 2
Burst = 3
Pipeline_Burst = 4
Synchronous = 5
Asynchronous = 6
}
Examples
Use $SupportedSRAM_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "SupportedSRAM" to friendly text
Note: to use other properties than "SupportedSRAM", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "SupportedSRAM"
# to translate other properties, use their translation table instead
$SupportedSRAM_map = @{
0 = 'Other'
1 = 'Unknown'
2 = 'Non-Burst'
3 = 'Burst'
4 = 'Pipeline Burst'
5 = 'Synchronous'
6 = 'Asynchronous'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "SupportedSRAM", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$SupportedSRAM = @{
Name = 'SupportedSRAM'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.SupportedSRAM)
{
# important: convert original value to [int] because
# hashtable keys are type-aware:
$SupportedSRAM_map[[int]$value]
}
# uncomment to get a comma-separated string instead
# of a string array:
$result <#-join ', '#>
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "SupportedSRAM". The latter
# is defined by the hashtable in $SupportedSRAM:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $SupportedSRAM
# ...or dump content of property SupportedSRAM:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $SupportedSRAM |
Select-Object -ExpandProperty SupportedSRAM
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $SupportedSRAM_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when there
is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$SupportedSRAM_map = @{
0 = 'Other'
1 = 'Unknown'
2 = 'Non-Burst'
3 = 'Burst'
4 = 'Pipeline Burst'
5 = 'Synchronous'
6 = 'Asynchronous'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property (hint: the property is an array!)
$rawValues = $instance.SupportedSRAM
# translate all raw values into friendly names:
$friendlyNames = foreach($rawValue in $rawValues)
{ $SupportedSRAM_map[[int]$rawValue] }
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "SupportedSRAM" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "SupportedSRAM", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "SupportedSRAM", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$SupportedSRAM = @{
Name = 'SupportedSRAM'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.SupportedSRAM)
{
switch([int]$value)
{
0 {'Other'}
1 {'Unknown'}
2 {'Non-Burst'}
3 {'Burst'}
4 {'Pipeline Burst'}
5 {'Synchronous'}
6 {'Asynchronous'}
default {"$value"}
}
}
$result
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "SupportedSRAM". The latter is defined
# by the hashtable in $SupportedSRAM:
Select-Object -Property Caption, $SupportedSRAM
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumSupportedSRAM
{
Other = 0
Unknown = 1
Non_Burst = 2
Burst = 3
Pipeline_Burst = 4
Synchronous = 5
Asynchronous = 6
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.SupportedSRAM
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **SupportedSRAM**
[EnumSupportedSRAM[]]$rawValue
# get a comma-separated string:
[EnumSupportedSRAM[]]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumSupportedSRAM[]]
#endregion
Enums must cover all possible values. If SupportedSRAM returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
SystemCreationClassName
Value of the scoping computer’s CreationClassName property.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, SystemCreationClassName
SystemLevelAddress
If True, the address information in the property ErrorAddress is a system-level address. If False, it is a physical address. If the ErrorInfo property is equal to 3, then this property has no meaning.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, SystemLevelAddress
SystemName
Name of the scoping system.
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property DeviceID, SystemName
WritePolicy
Write policy definition.
This value comes from the Cache Configuration member of the Cache Information structure in the SMBIOS information.
WritePolicy returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$WritePolicy_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Write Back'
4 = 'Write Through'
5 = 'Varies with Address'
6 = 'Determination Per I/O'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Write Back'}
4 {'Write Through'}
5 {'Varies with Address'}
6 {'Determination Per I/O'}
default {"$value"}
}
Use Enum structure
Enum EnumWritePolicy
{
Other = 1
Unknown = 2
Write_Back = 3
Write_Through = 4
Varies_with_Address = 5
Determination_Per_IO = 6
}
Examples
Use $WritePolicy_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "WritePolicy" to friendly text
Note: to use other properties than "WritePolicy", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "WritePolicy"
# to translate other properties, use their translation table instead
$WritePolicy_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Write Back'
4 = 'Write Through'
5 = 'Varies with Address'
6 = 'Determination Per I/O'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "WritePolicy", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$WritePolicy = @{
Name = 'WritePolicy'
Expression = {
# property is an array, so process all values
$value = $_.WritePolicy
$WritePolicy_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "WritePolicy". The latter
# is defined by the hashtable in $WritePolicy:
Get-CimInstance -Class Win32_CacheMemory | Select-Object -Property Caption, $WritePolicy
# ...or dump content of property WritePolicy:
$friendlyValues = Get-CimInstance -Class Win32_CacheMemory |
Select-Object -Property $WritePolicy |
Select-Object -ExpandProperty WritePolicy
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $WritePolicy_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_CacheMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_CacheMemory"
# to translate other properties, use their translation table instead
$WritePolicy_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Write Back'
4 = 'Write Through'
5 = 'Varies with Address'
6 = 'Determination Per I/O'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.WritePolicy
# translate raw value to friendly text:
$friendlyName = $WritePolicy_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "WritePolicy" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "WritePolicy", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "WritePolicy", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$WritePolicy = @{
Name = 'WritePolicy'
Expression = {
# property is an array, so process all values
$value = $_.WritePolicy
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Write Back'}
4 {'Write Through'}
5 {'Varies with Address'}
6 {'Determination Per I/O'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_CacheMemory |
# ...and output properties "Caption" and "WritePolicy". The latter is defined
# by the hashtable in $WritePolicy:
Select-Object -Property Caption, $WritePolicy
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_CacheMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumWritePolicy
{
Other = 1
Unknown = 2
Write_Back = 3
Write_Through = 4
Varies_with_Address = 5
Determination_Per_IO = 6
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_CacheMemory | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.WritePolicy
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **WritePolicy**
[EnumWritePolicy]$rawValue
# get a comma-separated string:
[EnumWritePolicy]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumWritePolicy]
#endregion
Enums must cover all possible values. If WritePolicy returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
Examples
List all instances of Win32_CacheMemory
Get-CimInstance -ClassName Win32_CacheMemory
Learn more about Get-CimInstance
and the deprecated Get-WmiObject
.
View all properties
Get-CimInstance -ClassName Win32_CacheMemory -Property *
View key properties only
Get-CimInstance -ClassName Win32_CacheMemory -KeyOnly
Selecting Properties
To select only some properties, pipe the results to Select-Object -Property a,b,c
with a comma-separated list of the properties you require. Wildcards are permitted.
Get-CimInstance
always returns all properties but only retrieves the ones that you specify. All other properties are empty but still present. That’s why you need to pipe the results into Select-Object
if you want to limit the visible properties, i.e. for reporting.
Selecting Properties
The code below lists all available properties. Remove the ones you do not need:
$properties = 'Access',
'AdditionalErrorData',
'Associativity',
'Availability',
'BlockSize',
'CacheSpeed',
'CacheType',
'Caption',
'ConfigManagerErrorCode',
'ConfigManagerUserConfig',
'CorrectableError',
'CreationClassName',
'CurrentSRAM',
'Description',
'DeviceID',
'EndingAddress',
'ErrorAccess',
'ErrorAddress',
'ErrorCleared',
'ErrorCorrectType',
'ErrorData',
'ErrorDataOrder',
'ErrorDescription',
'ErrorInfo',
'ErrorMethodology',
'ErrorResolution',
'ErrorTime',
'ErrorTransferSize',
'FlushTimer',
'InstallDate',
'InstalledSize',
'LastErrorCode',
'Level',
'LineSize',
'Location',
'MaxCacheSize',
'Name',
'NumberOfBlocks',
'OtherErrorDescription',
'PNPDeviceID',
'PowerManagementCapabilities',
'PowerManagementSupported',
'Purpose',
'ReadPolicy',
'ReplacementPolicy',
'StartingAddress',
'Status',
'StatusInfo',
'SupportedSRAM',
'SystemCreationClassName',
'SystemLevelAddress',
'SystemName',
'WritePolicy'
Get-CimInstance -ClassName Win32_CacheMemory | Select-Object -Property $properties
Limiting Network Bandwidth
If you work remotely, it makes sense to limit network bandwidth by filtering the properties on the server side, too:
Get-CimInstance -Class Win32_CacheMemory -Property $property |
Select-Object -Property $property
Selecting Instances
To select some instances, use Get-CimInstance and a WMI Query. The wildcard character in WMI Queries is % (and not “*”).
The parameter -Filter runs a simple query.
Listing all instances where the property Caption starts with “A”
Get-CimInstance -Class Win32_CacheMemory -Filter 'Caption LIKE "a%"'
Using a WQL Query
The parameter -Query uses a query similar to SQL and combines the parameters -Filter and -Property. This returns all instances where the property Caption starts with “A”, and returns the properties specified:
Get-CimInstance -Query "SELECT LineSize, ErrorDataOrder, BlockSize, ReadPolicy FROM Win32_CacheMemory WHERE Caption LIKE 'a%'"
Any property you did not specify is still present but empty. You might need to use
Select-Object
to remove all unwanted properties:Get-CimInstance -Query "SELECT LineSize, ErrorDataOrder, BlockSize, ReadPolicy FROM Win32_CacheMemory WHERE Caption LIKE 'a%'" | Select-Object -Property LineSize, ErrorDataOrder, BlockSize, ReadPolicy
Accessing Remote Computers
To access remote systems, you need to have proper permissions. User the parameter -ComputerName to access one or more remote systems.
Authenticating as Current User
# one or more computer names or IP addresses:
$list = 'server1', 'server2'
# authenticate with your current identity:
$result = Get-CimInstance -ClassName Win32_CacheMemory -ComputerName $list
$result
Authenticating as Different User
Use a CIMSession object to authenticate with a new identity:
# one or more computer names or IP addresses:
$list = 'server1', 'server2'
# authenticate with a different identity:
$cred = Get-Credential -Message 'Authenticate to retrieve WMI information:'
$session = New-CimSession -ComputerName $list -Credential $cred
$result = Get-CimInstance Win32_CacheMemory -CimSession $session
# remove the session after use (if you do not plan to re-use it later)
Remove-CimSession -CimSession $session
$result
Learn more about accessing remote computers.
Requirements
To use Win32_CacheMemory, the following requirements apply:
PowerShell
Get-CimInstance
was introduced with PowerShell Version 3.0, which in turn was introduced on clients with Windows 8 and on servers with Windows Server 2012.
If necessary, update Windows PowerShell to Windows PowerShell 5.1, or install PowerShell 7 side-by-side.
Operating System
Win32_CacheMemory was introduced on clients with Windows Vista and on servers with Windows Server 2008.
Namespace
Win32_CacheMemory lives in the Namespace Root/CIMV2. This is the default namespace. There is no need to use the -Namespace parameter in Get-CimInstance
.
Implementation
Win32_CacheMemory is implemented in CIMWin32.dll and defined in CIMWin32.mof. Both files are located in the folder C:\Windows\system32\wbem
:
explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\CIMWin32.mof