Finding out what RAM DIMMs are installed on a computer without opening the box

September 9th, 2014 by and tagged , , , ,

OK, so I needed to know exactly what RAM was installed on a computer and how many slots there were. I could have had the user shutdown his machine, opened up the box, got out a flashlight, popped out the DIMMs, written down the obscure part numbers, plugged them back in, and closed it up. But not only was that way too much like work, it would totally have disrupted his workday. So, instead, I let PowerShell and WMI do the heavy lisfting. The following script will get the currently installed memory modules, the maximum RAM supported on the computer, and the number slots available.

# Script Name: Get-MemoryModule.ps1
# Script to get the number of memory slots, and the installed memory, on
# the local computer. Could easily be updated to go against remote computers.
# ModHist: 12/29/2012 - initial, Charlie.
#        : 08/26/2014 - Charlie. Added logic to get slots and max RAM.
#        :
$strComputer = "."
$ComputerName = (hostname)
$colSlots = Get-WmiObject `
               -class "Win32_PhysicalMemoryArray" `
               -namespace "root\CIMV2" `
               -Computername $strComputer
$nSlots = $colSlots.MemoryDevices
$nMax = $colSlots.MaxCapacity
$gbMax = $nMax/(1024*1024)
$colModules = Get-WMIObject `
                -class "Win32_PhysicalMemory" `
                -namespace "root\CIMV2" `
                -computername $strComputer
foreach ($objItem in $colModules) {
   Write-host "Bank Label: " $objItem.BankLabel
   write-host "Capacity: " $objItem.Capacity
   write-host "Caption: " $objItem.Caption
   write-host "Creation Class Name: " $objItem.CreationClassName
   write-host "Data Width: " $objItem.DataWidth
   write-host "Description: " $objItem.Description
   write-host "Device Locator: " $objItem.DeviceLocator
   write-host "Form Factor: " $objItem.FormFactor
   write-host "Hot-Swappable: " $objItem.HotSwappable
   write-host "Installation Date: " $objItem.InstallDate
   write-host "Interleave Data Depth: " $objItem.InterleaveDataDepth
   write-host "Interleave Position: " $objItem.InterleavePosition
   write-host "Manufacturer: " $objItem.Manufacturer
   write-host "Memory Type: " $objItem.MemoryType
   write-host "Model: " $objItem.Model
   write-host "Name: " $objItem.Name
   write-host "Other Identifying Information: " $objItem.OtherIdentifyingInfo
   write-host "Part Number: " $objItem.PartNumber
   write-host "Position In Row: " $objItem.PositionInRow
   write-host "Powered-On: " $objItem.PoweredOn
   write-host "Removable: " $objItem.Removable
   write-host "Replaceable: " $objItem.Replaceable
   write-host "Serial Number: " $objItem.SerialNumber
   write-host "SKU: " $objItem.SKU
   write-host "Speed: " $objItem.Speed
   write-host "Status: " $objItem.Status
   write-host "Tag: " $objItem.Tag
   write-host "Total Width: " $objItem.TotalWidth
   write-host "Type Detail: " $objItem.TypeDetail
   write-host "Version: " $objItem.Version

Write-Host -nonewline "Computer $ComputerName has $nSlots Memory Slots, and a Maximum" 
write-host "Memory of $gbMax GigaBytes of RAM" $colModules `
     | ft -auto "BankLabel",@{Label="CurrentMem(MB)";Expression={$_.Capacity/(1024*1024)}},"Speed"

I’ve shown the “local” version of this, but it would be trivial to modify the script to run against a remote computer by adding support for a –ComputerName parameter. Also, at least some computers (most notably laptops) will not report their maximum supported memory correctly. I’ve run this script against the 6 physical computers running here and all worked fine expect for my HP laptop. That has 16 GB of RAM in it, but says the maximum RAM is 8 GB.

Posted in Hardware, PowerShell, WMI | Comments Off on Finding out what RAM DIMMs are installed on a computer without opening the box

Comments are closed.