Recipes by topic

Installed memory, module by module

Win32_PhysicalMemory returns one instance per module. The script reads the slot, capacity, part number and speed, then computes the total.

$memoryType = @{
    20 = 'DDR'
    21 = 'DDR2'
    24 = 'DDR3'
    26 = 'DDR4'
    34 = 'DDR5'
}

$module = @(Get-CimInstance -ClassName Win32_PhysicalMemory)

$module |
    Select-Object -Property @(
        'DeviceLocator'
        'Manufacturer'
        'PartNumber'
        @{ Name = 'CapacityGB'; Expression = { $_.Capacity / 1GB } }
        @{ Name = 'Type'; Expression = { $memoryType[[int]$_.SMBIOSMemoryType] } }
        'ConfiguredClockSpeed'
    )

$total = ($module | Measure-Object -Property Capacity -Sum).Sum
Write-Output -InputObject ('Total: {0} GB' -f ($total / 1GB))

SMBIOSMemoryType is a code: the table maps the common values to their name (the full list is on the class page). ConfiguredClockSpeed is the speed actually in use, Speed is the rated speed of the module. The class lists only the modules that are present, not the empty slots.

Variant: remote

On a fleet, compare the modules machine by machine before ordering upgrades.

$cimSession = New-CimSession -ComputerName 'PC01', 'PC02'
try {
    $cimParameters = @{
        CimSession = $cimSession
        ClassName  = 'Win32_PhysicalMemory'
    }
    Get-CimInstance @cimParameters |
        Select-Object -Property PSComputerName, DeviceLocator, Capacity, ConfiguredClockSpeed
} finally {
    Remove-CimSession -CimSession $cimSession
}

Classes used

← All recipes