Skip to content

Instantly share code, notes, and snippets.

@sheepla
Created April 29, 2023 09:23
Show Gist options
  • Save sheepla/ecf3c2e51115f0313ff1b48020f6aae5 to your computer and use it in GitHub Desktop.
Save sheepla/ecf3c2e51115f0313ff1b48020f6aae5 to your computer and use it in GitHub Desktop.
Get physical memory device detailed info on Windows
<#
.DESCRIPTION
Get physical memory (RAM) detailed information
#>
using namespace System.Collections.Generic
$memoryType = [Dictionary[int,string]]::new()
$memoryType.Add(0,"Unknown")
$memoryType.Add(1,"Other")
$memoryType.Add(2,"DRAM")
$memoryType.Add(3,"Synchronous DRAM")
$memoryType.Add(4,"Cache DRAM")
$memoryType.Add(5,"EDO")
$memoryType.Add(6,"EDRAM")
$memoryType.Add(7,"VRAM")
$memoryType.Add(8,"SRAM")
$memoryType.Add(9,"RAM")
$memoryType.Add(10,"ROM")
$memoryType.Add(11,"Flash")
$memoryType.Add(12,"EEPROM")
$memoryType.Add(13,"FEPROM")
$memoryType.Add(14,"EPROM")
$memoryType.Add(15,"CDRAM")
$memoryType.Add(16,"3DRAM")
$memoryType.Add(17,"SDRAM")
$memoryType.Add(18,"SGRAM")
$memoryType.Add(19,"RDRAM")
$memoryType.Add(20,"DDR")
$memoryType.Add(21,"DDR2")
$memoryType.Add(22,"DDR2 FB-DIMM")
$memoryType.Add(24,"DDR3")
$memoryType.Add(25,"FBD2")
Get-CimInstance -Namespace:"root/cimv2" Win32_PhysicalMemory | %{
[pscustomobject] @{
Tag = $_."Tag"
Caption = $_."Caption"
Manufacturer = $_."Manufacturer"
# PartNumber = $_."PartNumber"
# SerialNumber = $_."SerialNumber"
Speed = $_."Speed"
MemoryType = $memoryType[$_."MemoryType"]
CapacityGiB = $_."Capacity" / 1GB
}
}
@sheepla
Copy link
Author

sheepla commented Apr 29, 2023

Output like this

> Get-PhysicalMemory.ps1 | ft

Tag               Caption    Manufacturer  Speed MemoryType CapacityGiB
---               -------    ------------  ----- ---------- -----------
Physical Memory 0 物理メモリ Samsung        1600 DDR3                 4
Physical Memory 1 物理メモリ Hynix/Hyundai  1600 DDR3                 4
Physical Memory 2 物理メモリ Hynix/Hyundai  1600 DDR3                 4
Physical Memory 3 物理メモリ Hynix/Hyundai  1600 DDR3                 4

@sheepla
Copy link
Author

sheepla commented Apr 29, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment