简体   繁体   中英

powershell listing Ram information

I am trying to find out what type of RAM is in a computer. I'd like to know whether the modules are UDIMM, RDIMM, LRDIMM or any other type. This would be very useful so I can plan what modules are going into what servers at the data center.

This is what I have so far:

Get-WmiObject Win32_PhysicalMemory |
        Select-Object PSComputerName, DeviceLocator, Manufacturer, PartNumber, 
        @{ label = "Size/GB"; expression = { $_.Capacity / 1GB } },
        Speed, Datawidth, TotalWidth |
        Format-Table -AutoSize

This is useful information but I'd like a column that tells me the type (UDIMM, RDIMM, LRDIMM) and a way to list the DIMMS that are empty as it will make it easier to see what DIMM is full/empty (but this isn't a huge problem).

this is not a duplicate as i am looking for the type of Ram that is stored on the servers so i know what Ram to buy and put in without having to travel a long way to find out i got the wrong type

The Win32_PhysicalMemory class documentation contains a reference for translating the MemoryType value to the type of memory module. Turn it into a hashtable for easy access:

$MemoryTypeMap = @{
    "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'
    "24" = 'DDR3'
    "25" = 'FBD2'
}

Get-WmiObject Win32_PhysicalMemory |Select @{Label = 'Type';Expression = {$MemoryTypeMap["$($_.MemoryType)"]}}

You can see which memory devices are in which slots by using the WMI class of CIM_PhyicalMemoryArray and CIM_MemoryDeviceLocation . I've used WBEMTest and Get-CimInstance , however, and it doesn't seem that Windows reports on which memory slots are open on the motherboard.

My best guess? You'll need to use the Win32_Baseboard class to report on the model of the motherboard, and do some legwork manually to see how many slots each model has. You can then use the data from CIM_MemoryDeviceLocation to determine how many slots are open.

An approach to do so might look like this.

$memorySlots = Get-CimInstance Win32_MemoryDeviceLocation
$motherBoard = Get-CimInstance win32_baseboard

switch ($motherBoard.Product){
    #find the motherboard models for the most common models and populate manually w/ count of ram slots 
    "0TM99H" {$Totalslots = 2}
    Default {$Totalslots = 4}
}

 Get-WmiObject Win32_PhysicalMemory |
        Select-Object PSComputerName, DeviceLocator, Manufacturer, PartNumber, 
        @{ label = "Size/GB"; expression = { $_.Capacity / 1GB } },
        Speed, Datawidth, TotalWidth, @{ label ="FreeSlots";exp={$Totalslots-$memorySlots.Count}}

It would look something like this:

PSComputerName : SLVER
DeviceLocator  : DIMM A
Manufacturer   : Elpida
PartNumber     : 8KTS51264HDZ-1G6E1
Size/GB        : 4
Speed          : 1600
Datawidth      : 64
TotalWidth     : 64
FreeSlots      : 0

PSComputerName : SLVER
DeviceLocator  : DIMM B
Manufacturer   : Elpida
PartNumber     : 8KTS51264HDZ-1G6E1
Size/GB        : 4
Speed          : 1600
Datawidth      : 64
TotalWidth     : 64
FreeSlots      : 0

Finally, you asked about memory type present, that also doesn't seem to be info that we know of, from a WMI perspective. Or rather, if WMI does know about it, I couldn't find it anywhere.

I think you'll need to do some manual work too there, gathering the memory part number, then manually research to determine what type of RAM it is, then finally add that info to the output by adding another Switch statement, as shown.

switch ($memorySpecs.PartNumber){
    "8KTS51264HDZ-1G6E1" {$RAMType='SoDimm'}
    Default {$RAMType="Unknown, research $($memorySpecs.PartNumber)"}
}

Update

Mathias provided an excellent method to look up RAM if the BIOS on that PC reports it to Windows. I've tested on a few systems, some report their RAM Type while others don't. For those that don't, you can reference the partNumber property as I've demoed above to manually look it up. After a few iterations, you should be able to gather the data and program your own exceptions, and wrap up this task.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM