The Win32_PhysicalMemoryArray® WMI class represents details about the computer system physical memory. This includes the number of memory devices, memory capacity available, and memory typeâfor example, system or video memory.
Methods
Win32_PhysicalMemoryArray has no methods. Inherited methods (IsCompatible) are not implemented.
Properties
Win32_PhysicalMemoryArray returns 28 properties:
'Caption','CreationClassName','Depth','Description','Height','HotSwappable',
'InstallDate','Location','Manufacturer','MaxCapacity','MaxCapacityEx','MemoryDevices',
'MemoryErrorCorrection','Model','Name','OtherIdentifyingInfo','PartNumber','PoweredOn','Removable',
'Replaceable','SerialNumber','SKU','Status','Tag','Use','Version','Weight','Width'
Unless explicitly marked as writeable, all properties are read-only. Read all properties for all instances:
Get-CimInstance -ClassName Win32_PhysicalMemoryArray -Property *
Most WMI classes return one or more instances.
When
Get-CimInstance
returns no result, then apparently no instances of class Win32_PhysicalMemoryArray 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).
Caption
Short description of the objectâa one-line string.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Caption
CreationClassName
Name of the first concrete class that appears 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 identified uniquely.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, CreationClassName
Depth
Depth of the physical packageâin inches.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Depth
Description
Description of the object.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Description
Height
Height of the physical packageâin inches.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Height
HotSwappable
If TRUE, a physical package can be hot-swapped (if it is possible to replace the element with a physically different but equivalent one while the containing package has power applied to it, is “on”). For example, a disk drive package inserted using SCA connectors is removable and can be hot-swapped. All packages that can be hot-swapped are inherently removable and replaceable.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, HotSwappable
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_PhysicalMemoryArray | Select-Object -Property Tag, InstallDate
Location
Physical location of the memory array.
This value comes from the Location member of the Physical Memory Array 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 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'System board or motherboard'
4 = 'ISA add-on card'
5 = 'EISA add-on card'
6 = 'PCI add-on card'
7 = 'MCA add-on card'
8 = 'PCMCIA add-on card'
9 = 'Proprietary add-on card'
10 = 'NuBus'
11 = 'PC-98/C20 add-on card'
12 = 'PC-98/C24 add-on card'
13 = 'PC-98/E add-on card'
14 = 'PC-98/Local bus add-on card'
}
Use a switch statement
switch([int]$value)
{
0 {'Reserved'}
1 {'Other'}
2 {'Unknown'}
3 {'System board or motherboard'}
4 {'ISA add-on card'}
5 {'EISA add-on card'}
6 {'PCI add-on card'}
7 {'MCA add-on card'}
8 {'PCMCIA add-on card'}
9 {'Proprietary add-on card'}
10 {'NuBus'}
11 {'PC-98/C20 add-on card'}
12 {'PC-98/C24 add-on card'}
13 {'PC-98/E add-on card'}
14 {'PC-98/Local bus add-on card'}
default {"$value"}
}
Use Enum structure
Enum EnumLocation
{
Reserved = 0
Other = 1
Unknown = 2
System_board_or_motherboard = 3
ISA_add_on_card = 4
EISA_add_on_card = 5
PCI_add_on_card = 6
MCA_add_on_card = 7
PCMCIA_add_on_card = 8
Proprietary_add_on_card = 9
NuBus = 10
PC_98C20_add_on_card = 11
PC_98C24_add_on_card = 12
PC_98E_add_on_card = 13
PC_98Local_bus_add_on_card = 14
}
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 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'System board or motherboard'
4 = 'ISA add-on card'
5 = 'EISA add-on card'
6 = 'PCI add-on card'
7 = 'MCA add-on card'
8 = 'PCMCIA add-on card'
9 = 'Proprietary add-on card'
10 = 'NuBus'
11 = 'PC-98/C20 add-on card'
12 = 'PC-98/C24 add-on card'
13 = 'PC-98/E add-on card'
14 = 'PC-98/Local bus add-on card'
}
#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_PhysicalMemoryArray | Select-Object -Property Caption, $Location
# ...or dump content of property Location:
$friendlyValues = Get-CimInstance -Class Win32_PhysicalMemoryArray |
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_PhysicalMemoryArray" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_PhysicalMemoryArray", 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_PhysicalMemoryArray"
# to translate other properties, use their translation table instead
$Location_map = @{
0 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'System board or motherboard'
4 = 'ISA add-on card'
5 = 'EISA add-on card'
6 = 'PCI add-on card'
7 = 'MCA add-on card'
8 = 'PCMCIA add-on card'
9 = 'Proprietary add-on card'
10 = 'NuBus'
11 = 'PC-98/C20 add-on card'
12 = 'PC-98/C24 add-on card'
13 = 'PC-98/E add-on card'
14 = 'PC-98/Local bus add-on card'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMemoryArray | 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 {'Reserved'}
1 {'Other'}
2 {'Unknown'}
3 {'System board or motherboard'}
4 {'ISA add-on card'}
5 {'EISA add-on card'}
6 {'PCI add-on card'}
7 {'MCA add-on card'}
8 {'PCMCIA add-on card'}
9 {'Proprietary add-on card'}
10 {'NuBus'}
11 {'PC-98/C20 add-on card'}
12 {'PC-98/C24 add-on card'}
13 {'PC-98/E add-on card'}
14 {'PC-98/Local bus add-on card'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_PhysicalMemoryArray |
# ...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_PhysicalMemoryArray", 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
{
Reserved = 0
Other = 1
Unknown = 2
System_board_or_motherboard = 3
ISA_add_on_card = 4
EISA_add_on_card = 5
PCI_add_on_card = 6
MCA_add_on_card = 7
PCMCIA_add_on_card = 8
Proprietary_add_on_card = 9
NuBus = 10
PC_98C20_add_on_card = 11
PC_98C24_add_on_card = 12
PC_98E_add_on_card = 13
PC_98Local_bus_add_on_card = 14
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMemoryArray | 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.
Manufacturer
Name of the organization responsible for producing the physical element.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Manufacturer
MaxCapacity
Use the MaxCapacityEx property instead.
This value comes from the Maximum Capacity member of the Physical Memory Array structure in the SMBIOS information.
Windows Server® 2012® R2, Windows® 8.1, Windows Server® 2012, Windows® 8, Windows Server® 2008® R2, Windows® 7, Windows Server® 2008 and Windows® Vista: Maximum memory size (in bytes) installable for this particular memory array. If the size is unknown, the property is given a value of 0 (zero).
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, MaxCapacity
MaxCapacityEx
Maximum memory size (in bytes) installable for this particular memory array. If the size is unknown, the property is given a value of 0 (zero).
This value comes from the Extended Maximum Capacity member of the Physical Memory Array structure in the SMBIOS information.
Windows Server® 2012® R2, Windows® 8.1, Windows Server® 2012, Windows® 8, Windows Server® 2008® R2, Windows® 7, Windows Server® 2008 and Windows® Vista: This property is not supported.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, MaxCapacityEx
MemoryDevices
Number of physical slots or sockets available in this memory array.
This value comes from the Number of Memory Devices member of the Physical Memory Array structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, MemoryDevices
MemoryErrorCorrection
Type of error correction used by the memory array.
This value comes from the Memory Error Correction member of the Physical Memory Array structure in the SMBIOS information.
MemoryErrorCorrection returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$MemoryErrorCorrection_map = @{
0 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'None'
4 = 'Parity'
5 = 'Single-bit ECC'
6 = 'Multi-bit ECC'
7 = 'CRC'
}
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'}
7 {'CRC'}
default {"$value"}
}
Use Enum structure
Enum EnumMemoryErrorCorrection
{
Reserved = 0
Other = 1
Unknown = 2
None = 3
Parity = 4
Single_bit_ECC = 5
Multi_bit_ECC = 6
CRC = 7
}
Examples
Use $MemoryErrorCorrection_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "MemoryErrorCorrection" to friendly text
Note: to use other properties than "MemoryErrorCorrection", 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 "MemoryErrorCorrection"
# to translate other properties, use their translation table instead
$MemoryErrorCorrection_map = @{
0 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'None'
4 = 'Parity'
5 = 'Single-bit ECC'
6 = 'Multi-bit ECC'
7 = 'CRC'
}
#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 "MemoryErrorCorrection", 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:
#>
$MemoryErrorCorrection = @{
Name = 'MemoryErrorCorrection'
Expression = {
# property is an array, so process all values
$value = $_.MemoryErrorCorrection
$MemoryErrorCorrection_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "MemoryErrorCorrection". The latter
# is defined by the hashtable in $MemoryErrorCorrection:
Get-CimInstance -Class Win32_PhysicalMemoryArray | Select-Object -Property Caption, $MemoryErrorCorrection
# ...or dump content of property MemoryErrorCorrection:
$friendlyValues = Get-CimInstance -Class Win32_PhysicalMemoryArray |
Select-Object -Property $MemoryErrorCorrection |
Select-Object -ExpandProperty MemoryErrorCorrection
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $MemoryErrorCorrection_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_PhysicalMemoryArray" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_PhysicalMemoryArray", 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_PhysicalMemoryArray"
# to translate other properties, use their translation table instead
$MemoryErrorCorrection_map = @{
0 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'None'
4 = 'Parity'
5 = 'Single-bit ECC'
6 = 'Multi-bit ECC'
7 = 'CRC'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMemoryArray | 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.MemoryErrorCorrection
# translate raw value to friendly text:
$friendlyName = $MemoryErrorCorrection_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 "MemoryErrorCorrection" 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 "MemoryErrorCorrection", 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 "MemoryErrorCorrection", 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:
#>
$MemoryErrorCorrection = @{
Name = 'MemoryErrorCorrection'
Expression = {
# property is an array, so process all values
$value = $_.MemoryErrorCorrection
switch([int]$value)
{
0 {'Reserved'}
1 {'Other'}
2 {'Unknown'}
3 {'None'}
4 {'Parity'}
5 {'Single-bit ECC'}
6 {'Multi-bit ECC'}
7 {'CRC'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_PhysicalMemoryArray |
# ...and output properties "Caption" and "MemoryErrorCorrection". The latter is defined
# by the hashtable in $MemoryErrorCorrection:
Select-Object -Property Caption, $MemoryErrorCorrection
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_PhysicalMemoryArray", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumMemoryErrorCorrection
{
Reserved = 0
Other = 1
Unknown = 2
None = 3
Parity = 4
Single_bit_ECC = 5
Multi_bit_ECC = 6
CRC = 7
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMemoryArray | 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.MemoryErrorCorrection
#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 **MemoryErrorCorrection**
[EnumMemoryErrorCorrection]$rawValue
# get a comma-separated string:
[EnumMemoryErrorCorrection]$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 [EnumMemoryErrorCorrection]
#endregion
Enums must cover all possible values. If MemoryErrorCorrection 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.
Model
Name by which the physical element is generally known.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Model
Name
Label by which the object is known. When subclassed, the property can be overridden to be a key property.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Name
OtherIdentifyingInfo
Additional data, beyond asset tag information, that could be used to identify a physical element. One example is bar code data associated with an element that also has an asset tag. Note that if only bar code data is available and is unique or able to be used as an element key, this property would be NULL and the bar code data used as the class key, in the tag property.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, OtherIdentifyingInfo
PartNumber
Part number assigned by the organization responsible for producing or manufacturing the physical element.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, PartNumber
PoweredOn
If TRUE, the physical element is powered on.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, PoweredOn
Removable
If TRUE, a physical package is removable (if it is designed to be taken in and out of the physical container in which it is normally found, without impairing the function of the overall packaging). A package can still be removable if power must be “off” to perform the removal. If power can be “on” and the package removed, then the element is removable and can be hot-swapped. For example, an extra battery in a laptop is removable, as is a disk drive package inserted using SCA connectors. However, the latter can be hot-swapped. A laptop’s display is not removable, nor is a nonredundant power supply. Removing these components would affect the function of the overall packaging or is impossible due to the tight integration of the package.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Removable
Replaceable
If TRUE, this physical media component can be replaced with a physically different one. For example, some computer systems allow the main processor chip to be upgraded to one of a higher clock rating. In this case, the processor is said to be replaceable. Another example is a power supply package mounted on sliding rails. All removable packages are inherently replaceable.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Replaceable
SerialNumber
Manufacturer-allocated number used to identify the physical element.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, SerialNumber
SKU
Stockkeeping unit number for the physical element.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, SKU
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_PhysicalMemoryArray | Select-Object -Property Tag, Status
Tag
KEY PROPERTY STRING MAX 256 CHAR
Unique identifier of the physical memory array.
Example: “Physical Memory Array 1”
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag
Use
How memory is used in the computer system.
This value comes from the Use member of the Physical Memory Array structure in the SMBIOS information.
Use returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$Use_map = @{
0 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'System memory'
4 = 'Video memory'
5 = 'Flash memory'
6 = 'Non-volatile RAM'
7 = 'Cache memory'
}
Use a switch statement
switch([int]$value)
{
0 {'Reserved'}
1 {'Other'}
2 {'Unknown'}
3 {'System memory'}
4 {'Video memory'}
5 {'Flash memory'}
6 {'Non-volatile RAM'}
7 {'Cache memory'}
default {"$value"}
}
Use Enum structure
Enum EnumUse
{
Reserved = 0
Other = 1
Unknown = 2
System_memory = 3
Video_memory = 4
Flash_memory = 5
Non_volatile_RAM = 6
Cache_memory = 7
}
Examples
Use $Use_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "Use" to friendly text
Note: to use other properties than "Use", 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 "Use"
# to translate other properties, use their translation table instead
$Use_map = @{
0 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'System memory'
4 = 'Video memory'
5 = 'Flash memory'
6 = 'Non-volatile RAM'
7 = 'Cache memory'
}
#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 "Use", 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:
#>
$Use = @{
Name = 'Use'
Expression = {
# property is an array, so process all values
$value = $_.Use
$Use_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "Use". The latter
# is defined by the hashtable in $Use:
Get-CimInstance -Class Win32_PhysicalMemoryArray | Select-Object -Property Caption, $Use
# ...or dump content of property Use:
$friendlyValues = Get-CimInstance -Class Win32_PhysicalMemoryArray |
Select-Object -Property $Use |
Select-Object -ExpandProperty Use
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $Use_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_PhysicalMemoryArray" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_PhysicalMemoryArray", 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_PhysicalMemoryArray"
# to translate other properties, use their translation table instead
$Use_map = @{
0 = 'Reserved'
1 = 'Other'
2 = 'Unknown'
3 = 'System memory'
4 = 'Video memory'
5 = 'Flash memory'
6 = 'Non-volatile RAM'
7 = 'Cache memory'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMemoryArray | 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.Use
# translate raw value to friendly text:
$friendlyName = $Use_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 "Use" 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 "Use", 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 "Use", 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:
#>
$Use = @{
Name = 'Use'
Expression = {
# property is an array, so process all values
$value = $_.Use
switch([int]$value)
{
0 {'Reserved'}
1 {'Other'}
2 {'Unknown'}
3 {'System memory'}
4 {'Video memory'}
5 {'Flash memory'}
6 {'Non-volatile RAM'}
7 {'Cache memory'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_PhysicalMemoryArray |
# ...and output properties "Caption" and "Use". The latter is defined
# by the hashtable in $Use:
Select-Object -Property Caption, $Use
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_PhysicalMemoryArray", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumUse
{
Reserved = 0
Other = 1
Unknown = 2
System_memory = 3
Video_memory = 4
Flash_memory = 5
Non_volatile_RAM = 6
Cache_memory = 7
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMemoryArray | 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.Use
#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 **Use**
[EnumUse]$rawValue
# get a comma-separated string:
[EnumUse]$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 [EnumUse]
#endregion
Enums must cover all possible values. If Use 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.
Version
Version of the physical element.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Version
Weight
Weight of the physical package in pounds.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Weight
Width
Width of the physical package in inches.
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | Select-Object -Property Tag, Width
Examples
List all instances of Win32_PhysicalMemoryArray
Get-CimInstance -ClassName Win32_PhysicalMemoryArray
Learn more about Get-CimInstance
and the deprecated Get-WmiObject
.
View all properties
Get-CimInstance -ClassName Win32_PhysicalMemoryArray -Property *
View key properties only
Get-CimInstance -ClassName Win32_PhysicalMemoryArray -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 = 'Caption',
'CreationClassName',
'Depth',
'Description',
'Height',
'HotSwappable',
'InstallDate',
'Location',
'Manufacturer',
'MaxCapacity',
'MaxCapacityEx',
'MemoryDevices',
'MemoryErrorCorrection',
'Model',
'Name',
'OtherIdentifyingInfo',
'PartNumber',
'PoweredOn',
'Removable',
'Replaceable',
'SerialNumber',
'SKU',
'Status',
'Tag',
'Use',
'Version',
'Weight',
'Width'
Get-CimInstance -ClassName Win32_PhysicalMemoryArray | 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_PhysicalMemoryArray -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_PhysicalMemoryArray -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 Weight, PoweredOn, Use, InstallDate FROM Win32_PhysicalMemoryArray 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 Weight, PoweredOn, Use, InstallDate FROM Win32_PhysicalMemoryArray WHERE Caption LIKE 'a%'" | Select-Object -Property Weight, PoweredOn, Use, InstallDate
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_PhysicalMemoryArray -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_PhysicalMemoryArray -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_PhysicalMemoryArray, 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_PhysicalMemoryArray was introduced on clients with Windows Vista and on servers with Windows Server 2008.
Namespace
Win32_PhysicalMemoryArray 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_PhysicalMemoryArray 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