The Win32_PhysicalMemory WMI class represents a physical memory device located on a computer system and available to the operating system.
Methods
Win32_PhysicalMemory has no methods.
Properties
Win32_PhysicalMemory returns 36 properties:
'Attributes','BankLabel','Capacity','Caption','ConfiguredClockSpeed',
'ConfiguredVoltage','CreationClassName','DataWidth','Description','DeviceLocator','FormFactor',
'HotSwappable','InstallDate','InterleaveDataDepth','InterleavePosition','Manufacturer','MaxVoltage',
'MemoryType','MinVoltage','Model','Name','OtherIdentifyingInfo','PartNumber','PositionInRow',
'PoweredOn','Removable','Replaceable','SerialNumber','SKU','SMBIOSMemoryType','Speed','Status',
'Tag','TotalWidth','TypeDetail','Version'
Unless explicitly marked as writeable, all properties are read-only. Read all properties for all instances:
Get-CimInstance -ClassName Win32_PhysicalMemory -Property *
Most WMI classes return one or more instances.
When
Get-CimInstance
returns no result, then apparently no instances of class Win32_PhysicalMemory 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).
Attributes
SMBIOS - Type 17 - Attributes. Represents the RANK.
This value comes from the Attributes member of the Memory Device 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 before Windows Server® 2016 and Windows® 10.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, Attributes
BankLabel
Physically labeled bank where the memory is located.
Examples: “Bank 0”, “Bank A”
This value comes from the Bank Locator member of the Memory Device structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, BankLabel
Capacity
Total capacity of the physical memoryâin bytes.
This value comes from the Memory Device structure in the SMBIOS version information. For SMBIOS versions 2.1 thru 2.6 the value comes from the Size member. For SMBIOS version 2.7+ the value comes from the Extended Size member.
For more information about using uint64 values in scripts, see Scripting in WMI.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, Capacity
Caption
Short description of the objectâa one-line string.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, Caption
ConfiguredClockSpeed
The configured clock speed of the memory device, in megahertz (MHz), or 0, if the speed is unknown.
This value comes from the Configured Memory Clock Speed member of the Memory Device 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 before Windows Server® 2016 and Windows® 10.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, ConfiguredClockSpeed
ConfiguredVoltage
Configured voltage for this device, in millivolts, or 0, if the voltage is unknown.
This value comes from the Configured voltage member of the Memory Device 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 before Windows Server® 2016 and Windows® 10.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, ConfiguredVoltage
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_PhysicalMemory | Select-Object -Property Tag, CreationClassName
DataWidth
Data width of the physical memoryâin bits. A data width of 0 (zero) and a total width of 8 (eight) indicates that the memory is used solely to provide error correction bits.
This value comes from the Data Width member of the Memory Device structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, DataWidth
Description
Description of an object.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, Description
DeviceLocator
Label of the socket or circuit board that holds the memory.
Example: “SIMM 3”
This value comes from the Device Locator member of the Memory Device structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, DeviceLocator
FormFactor
Implementation form factor for the chip.
This value comes from the Form Factor member of the Memory Device structure in the SMBIOS information.
(0)
Unknown
(1)
Other
(2)
SIP
(3)
DIP
(4)
ZIP
(5)
SOJ
(6)
Proprietary
(7)
SIMM
(8)
DIMM
(9)
TSOP
(10)
PGA
(11)
RIMM
(12)
SODIMM
(13)
SRIMM
(14)
SMD
(15)
SSMP
(16)
QFP
(17)
TQFP
(18)
SOIC
(19)
LCC
(20)
PLCC
(21)
BGA
(22)
FPBGA
(23)
LGA
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, FormFactor
HotSwappable
If TRUE, this physical media component can be replaced with a physically different but equivalent one while the containing package has the power applied. For example, a fan component may be designed to be hot-swapped. All components that can be hot-swapped are inherently removable and replaceable.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, HotSwappable
InstallDate
Date and time the object is installed. This property does not need a value to indicate that the object is installed.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, InstallDate
InterleaveDataDepth
Unsigned 16-bit integer maximum number of consecutive rows of data that are accessed in a single interleaved transfer from the memory device. If the value is 0 (zero), the memory is not interleaved.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, InterleaveDataDepth
InterleavePosition
Position of the physical memory in an interleave. For example, in a 2:1 interleave, a value of “1” indicates that the memory is in the “even” position.
0
Noninterleaved
1
First position
2
Second position
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, InterleavePosition
Manufacturer
Name of the organization responsible for producing the physical element.
This value comes from the Manufacturer member of the Memory Device structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, Manufacturer
MaxVoltage
The maximum operating voltage for this device, in millivolts, or 0, if the voltage is unknown.
This value comes from the Maximum voltage member of the Memory Device 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 before Windows Server® 2016 and Windows® 10.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, MaxVoltage
MemoryType
Type of physical memory. This is a CIM value that is mapped to the SMBIOS value. The SMBIOSMemoryType property contains the raw SMBIOS memory type.
This value comes from the Memory Type member of the Memory Device structure in the SMBIOS information.
MemoryType returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$MemoryType_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'DRAM'
3 = 'Synchronous DRAM'
4 = 'Cache DRAM'
5 = 'EDO'
6 = 'EDRAM'
7 = 'VRAM'
8 = 'SRAM'
9 = 'RAM'
10 = 'ROM'
11 = 'Flash'
12 = 'EEPROM'
13 = 'FEPROM'
14 = 'EPROM'
15 = 'CDRAM'
16 = '3DRAM'
17 = 'SDRAM'
18 = 'SGRAM'
19 = 'RDRAM'
20 = 'DDR'
21 = 'DDR2'
22 = 'DDR2 FB-DIMM'
}
Use a switch statement
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'DRAM'}
3 {'Synchronous DRAM'}
4 {'Cache DRAM'}
5 {'EDO'}
6 {'EDRAM'}
7 {'VRAM'}
8 {'SRAM'}
9 {'RAM'}
10 {'ROM'}
11 {'Flash'}
12 {'EEPROM'}
13 {'FEPROM'}
14 {'EPROM'}
15 {'CDRAM'}
16 {'3DRAM'}
17 {'SDRAM'}
18 {'SGRAM'}
19 {'RDRAM'}
20 {'DDR'}
21 {'DDR2'}
22 {'DDR2 FB-DIMM'}
default {"$value"}
}
Use Enum structure
Enum EnumMemoryType
{
Unknown = 0
Other = 1
DRAM = 2
Synchronous_DRAM = 3
Cache_DRAM = 4
EDO = 5
EDRAM = 6
VRAM = 7
SRAM = 8
RAM = 9
ROM = 10
Flash = 11
EEPROM = 12
FEPROM = 13
EPROM = 14
CDRAM = 15
_3DRAM = 16
SDRAM = 17
SGRAM = 18
RDRAM = 19
DDR = 20
DDR2 = 21
DDR2_FB_DIMM = 22
}
Examples
Use $MemoryType_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "MemoryType" to friendly text
Note: to use other properties than "MemoryType", 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 "MemoryType"
# to translate other properties, use their translation table instead
$MemoryType_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'DRAM'
3 = 'Synchronous DRAM'
4 = 'Cache DRAM'
5 = 'EDO'
6 = 'EDRAM'
7 = 'VRAM'
8 = 'SRAM'
9 = 'RAM'
10 = 'ROM'
11 = 'Flash'
12 = 'EEPROM'
13 = 'FEPROM'
14 = 'EPROM'
15 = 'CDRAM'
16 = '3DRAM'
17 = 'SDRAM'
18 = 'SGRAM'
19 = 'RDRAM'
20 = 'DDR'
21 = 'DDR2'
22 = 'DDR2 FB-DIMM'
}
#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 "MemoryType", 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:
#>
$MemoryType = @{
Name = 'MemoryType'
Expression = {
# property is an array, so process all values
$value = $_.MemoryType
$MemoryType_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "MemoryType". The latter
# is defined by the hashtable in $MemoryType:
Get-CimInstance -Class Win32_PhysicalMemory | Select-Object -Property Caption, $MemoryType
# ...or dump content of property MemoryType:
$friendlyValues = Get-CimInstance -Class Win32_PhysicalMemory |
Select-Object -Property $MemoryType |
Select-Object -ExpandProperty MemoryType
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $MemoryType_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_PhysicalMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_PhysicalMemory", 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_PhysicalMemory"
# to translate other properties, use their translation table instead
$MemoryType_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'DRAM'
3 = 'Synchronous DRAM'
4 = 'Cache DRAM'
5 = 'EDO'
6 = 'EDRAM'
7 = 'VRAM'
8 = 'SRAM'
9 = 'RAM'
10 = 'ROM'
11 = 'Flash'
12 = 'EEPROM'
13 = 'FEPROM'
14 = 'EPROM'
15 = 'CDRAM'
16 = '3DRAM'
17 = 'SDRAM'
18 = 'SGRAM'
19 = 'RDRAM'
20 = 'DDR'
21 = 'DDR2'
22 = 'DDR2 FB-DIMM'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMemory | 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.MemoryType
# translate raw value to friendly text:
$friendlyName = $MemoryType_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 "MemoryType" 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 "MemoryType", 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 "MemoryType", 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:
#>
$MemoryType = @{
Name = 'MemoryType'
Expression = {
# property is an array, so process all values
$value = $_.MemoryType
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'DRAM'}
3 {'Synchronous DRAM'}
4 {'Cache DRAM'}
5 {'EDO'}
6 {'EDRAM'}
7 {'VRAM'}
8 {'SRAM'}
9 {'RAM'}
10 {'ROM'}
11 {'Flash'}
12 {'EEPROM'}
13 {'FEPROM'}
14 {'EPROM'}
15 {'CDRAM'}
16 {'3DRAM'}
17 {'SDRAM'}
18 {'SGRAM'}
19 {'RDRAM'}
20 {'DDR'}
21 {'DDR2'}
22 {'DDR2 FB-DIMM'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_PhysicalMemory |
# ...and output properties "Caption" and "MemoryType". The latter is defined
# by the hashtable in $MemoryType:
Select-Object -Property Caption, $MemoryType
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_PhysicalMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumMemoryType
{
Unknown = 0
Other = 1
DRAM = 2
Synchronous_DRAM = 3
Cache_DRAM = 4
EDO = 5
EDRAM = 6
VRAM = 7
SRAM = 8
RAM = 9
ROM = 10
Flash = 11
EEPROM = 12
FEPROM = 13
EPROM = 14
CDRAM = 15
_3DRAM = 16
SDRAM = 17
SGRAM = 18
RDRAM = 19
DDR = 20
DDR2 = 21
DDR2_FB_DIMM = 22
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMemory | 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.MemoryType
#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 **MemoryType**
[EnumMemoryType]$rawValue
# get a comma-separated string:
[EnumMemoryType]$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 [EnumMemoryType]
#endregion
Enums must cover all possible values. If MemoryType 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.
MinVoltage
The minimum operating voltage for this device, in millivolts, or 0, if the voltage is unknown.
This value comes from the Minimum voltage member of the Memory Device 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 before Windows Server® 2016 and Windows® 10.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, MinVoltage
Model
Name for the physical element.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, Model
Name
Label for the object. When subclassed, the property can be overridden to be a key property.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, Name
OtherIdentifyingInfo
Additional data, beyond asset tag information, that can be used to identify a physical element. One example is bar code data associated with an element that also has an asset tag. If only bar code data is available and unique or able to be used as an element key, this property is be NULL and the bar code data is used as the class key in the tag property.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, OtherIdentifyingInfo
PartNumber
Part number assigned by the organization responsible for producing or manufacturing the physical element.
This value comes from the Part Number member of the Memory Device structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, PartNumber
PositionInRow
Position of the physical memory in a row. For example, if it takes two 8-bit memory devices to form a 16-bit row, then a value of 2 (two) means that this memory is the second deviceâ0 (zero) is an invalid value for this property.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, PositionInRow
PoweredOn
If TRUE, the physical element is powered on.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, PoweredOn
Removable
If TRUE, a physical component 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 component can still be removable if power must be “off” to perform the removal. If power can be “on” and the component removed, then the element is removable and can be hot-swapped. For example, an upgradable processor chip is removable.
Get-CimInstance -ClassName Win32_PhysicalMemory | 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. All removable components are inherently replaceable.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, Replaceable
SerialNumber
Manufacturer-allocated number to identify the physical element.
This value comes from the Serial Number member of the Memory Device structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, SerialNumber
SKU
Stock keeping unit number for the physical element.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, SKU
SMBIOSMemoryType
The raw SMBIOS memory type. The value of the MemoryType property is a CIM value that is mapped to the SMBIOS value.
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 before Windows Server® 2016 and Windows® 10.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, SMBIOSMemoryType
Speed
Speed of the physical memoryâin nanoseconds.
This value comes from the Speed member of the Memory Device structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, Speed
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_PhysicalMemory | Select-Object -Property Tag, Status
Tag
KEY PROPERTY STRING MAX 256 CHAR
Example: “Physical Memory 1”
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag
TotalWidth
Total width, in bits, of the physical memory, including check or error correction bits. If there are no error correction bits, the value in this property should match what is specified for the DataWidth property.
This value comes from the Total Width member of the Memory Device structure in the SMBIOS information.
Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object -Property Tag, TotalWidth
TypeDetail
Type of physical memory represented.
This value comes from the Type Detail member of the Memory Device structure in the SMBIOS information.
TypeDetail returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$TypeDetail_map = @{
1 = 'Reserved'
2 = 'Other'
4 = 'Unknown'
8 = 'Fast-paged'
16 = 'Static column'
32 = 'Pseudo-static'
64 = 'RAMBUS'
128 = 'Synchronous'
256 = 'CMOS'
512 = 'EDO'
1024 = 'Window DRAM'
2048 = 'Cache DRAM'
4096 = 'Non-volatile'
}
Use a switch statement
switch([int]$value)
{
1 {'Reserved'}
2 {'Other'}
4 {'Unknown'}
8 {'Fast-paged'}
16 {'Static column'}
32 {'Pseudo-static'}
64 {'RAMBUS'}
128 {'Synchronous'}
256 {'CMOS'}
512 {'EDO'}
1024 {'Window DRAM'}
2048 {'Cache DRAM'}
4096 {'Non-volatile'}
default {"$value"}
}
Use Enum structure
Enum EnumTypeDetail
{
Reserved = 1
Other = 2
Unknown = 4
Fast_paged = 8
Static_column = 16
Pseudo_static = 32
RAMBUS = 64
Synchronous = 128
CMOS = 256
EDO = 512
Window_DRAM = 1024
Cache_DRAM = 2048
Non_volatile = 4096
}
Examples
Use $TypeDetail_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "TypeDetail" to friendly text
Note: to use other properties than "TypeDetail", 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 "TypeDetail"
# to translate other properties, use their translation table instead
$TypeDetail_map = @{
1 = 'Reserved'
2 = 'Other'
4 = 'Unknown'
8 = 'Fast-paged'
16 = 'Static column'
32 = 'Pseudo-static'
64 = 'RAMBUS'
128 = 'Synchronous'
256 = 'CMOS'
512 = 'EDO'
1024 = 'Window DRAM'
2048 = 'Cache DRAM'
4096 = 'Non-volatile'
}
#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 "TypeDetail", 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:
#>
$TypeDetail = @{
Name = 'TypeDetail'
Expression = {
# property is an array, so process all values
$value = $_.TypeDetail
$TypeDetail_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "TypeDetail". The latter
# is defined by the hashtable in $TypeDetail:
Get-CimInstance -Class Win32_PhysicalMemory | Select-Object -Property Caption, $TypeDetail
# ...or dump content of property TypeDetail:
$friendlyValues = Get-CimInstance -Class Win32_PhysicalMemory |
Select-Object -Property $TypeDetail |
Select-Object -ExpandProperty TypeDetail
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $TypeDetail_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_PhysicalMemory" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_PhysicalMemory", 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_PhysicalMemory"
# to translate other properties, use their translation table instead
$TypeDetail_map = @{
1 = 'Reserved'
2 = 'Other'
4 = 'Unknown'
8 = 'Fast-paged'
16 = 'Static column'
32 = 'Pseudo-static'
64 = 'RAMBUS'
128 = 'Synchronous'
256 = 'CMOS'
512 = 'EDO'
1024 = 'Window DRAM'
2048 = 'Cache DRAM'
4096 = 'Non-volatile'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMemory | 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.TypeDetail
# translate raw value to friendly text:
$friendlyName = $TypeDetail_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 "TypeDetail" 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 "TypeDetail", 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 "TypeDetail", 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:
#>
$TypeDetail = @{
Name = 'TypeDetail'
Expression = {
# property is an array, so process all values
$value = $_.TypeDetail
switch([int]$value)
{
1 {'Reserved'}
2 {'Other'}
4 {'Unknown'}
8 {'Fast-paged'}
16 {'Static column'}
32 {'Pseudo-static'}
64 {'RAMBUS'}
128 {'Synchronous'}
256 {'CMOS'}
512 {'EDO'}
1024 {'Window DRAM'}
2048 {'Cache DRAM'}
4096 {'Non-volatile'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_PhysicalMemory |
# ...and output properties "Caption" and "TypeDetail". The latter is defined
# by the hashtable in $TypeDetail:
Select-Object -Property Caption, $TypeDetail
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_PhysicalMemory", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumTypeDetail
{
Reserved = 1
Other = 2
Unknown = 4
Fast_paged = 8
Static_column = 16
Pseudo_static = 32
RAMBUS = 64
Synchronous = 128
CMOS = 256
EDO = 512
Window_DRAM = 1024
Cache_DRAM = 2048
Non_volatile = 4096
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMemory | 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.TypeDetail
#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 **TypeDetail**
[EnumTypeDetail]$rawValue
# get a comma-separated string:
[EnumTypeDetail]$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 [EnumTypeDetail]
#endregion
Enums must cover all possible values. If TypeDetail 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_PhysicalMemory | Select-Object -Property Tag, Version
Examples
List all instances of Win32_PhysicalMemory
Get-CimInstance -ClassName Win32_PhysicalMemory
Learn more about Get-CimInstance
and the deprecated Get-WmiObject
.
View all properties
Get-CimInstance -ClassName Win32_PhysicalMemory -Property *
View key properties only
Get-CimInstance -ClassName Win32_PhysicalMemory -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 = 'Attributes',
'BankLabel',
'Capacity',
'Caption',
'ConfiguredClockSpeed',
'ConfiguredVoltage',
'CreationClassName',
'DataWidth',
'Description',
'DeviceLocator',
'FormFactor',
'HotSwappable',
'InstallDate',
'InterleaveDataDepth',
'InterleavePosition',
'Manufacturer',
'MaxVoltage',
'MemoryType',
'MinVoltage',
'Model',
'Name',
'OtherIdentifyingInfo',
'PartNumber',
'PositionInRow',
'PoweredOn',
'Removable',
'Replaceable',
'SerialNumber',
'SKU',
'SMBIOSMemoryType',
'Speed',
'Status',
'Tag',
'TotalWidth',
'TypeDetail',
'Version'
Get-CimInstance -ClassName Win32_PhysicalMemory | 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_PhysicalMemory -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_PhysicalMemory -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 FormFactor, InterleavePosition, SMBIOSMemoryType, Speed FROM Win32_PhysicalMemory 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 FormFactor, InterleavePosition, SMBIOSMemoryType, Speed FROM Win32_PhysicalMemory WHERE Caption LIKE 'a%'" | Select-Object -Property FormFactor, InterleavePosition, SMBIOSMemoryType, Speed
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_PhysicalMemory -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_PhysicalMemory -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_PhysicalMemory, 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_PhysicalMemory was introduced on clients with Windows Vista and on servers with Windows Server 2008.
Namespace
Win32_PhysicalMemory 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_PhysicalMemory 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