Zack Zack - 3 months ago 14
PowerShell Question

How to find MAX RAM in powershell

How to find the maximum RAM a computer can be extended upto in powershell.
I tried using

$colItems3 = get-wmiobject -class "Win32_OperatingSystem"


but the answer is not correct

Answer

For installed RAM you want:

Get-WmiObject Win32_PhysicalMemory | Where {$_.MemoryType -ge 20} | 
    Measure Capacity -sum

Look at this MSDN page for more info on MemoryType.

For the MAX amount of RAM the system will handle, I think this is supposed to get you that. However, I don't think that means the OS or the motherboard would necessarily handle that much memory. I see nothing on the Win32_MotherboardDevice that shows max RAM.

Get-WmiObject Win32_PhysicalMemoryArray | Where {$_.Use -eq 3} | 
    Foreach {($_.MaxCapacity*1KB)/1GB}

Here's the MSDN page for Win32_PhysicalMemoryArray.