Getting RAM info on Local or Remote Computer in PowerShell

You can get information about the RAM installed on your computer through some built-in System Info tools or various 3rd party system inventory utilities such as CPU-Z, or AIDA32. But here I am going to talk about how to use PowerShell, the built-in script tool that comes with Windows, to extract the same info from your local and remote computers.

How many memory slots do I have?

You can simply run the following cmdlet in PowerShell window to find out.

Get-WmiObject -class "Win32_PhysicalMemoryArray"

The MemoryDevices column indicates how many memory slots are available in your computer while MaxCapacity tells you how much total of RAM you can install.

PowerShell - total slot

To get the info from a remote computer, use -computername switch to the cmdlet. For example,

Get-WmiObject -class "Win32_PhysicalMemoryArray" -computername C-20141222B

PowerShell - total slot remote computer

How many memory sticks and total of RAM installed?

The following cmdlet reveals this information in a single run.

Get-WmiObject Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum

And again, adding -computername switch in the end if you want to get the info from a remote computer.

Get-WmiObject Win32_PhysicalMemory -computername C-20141222B | Measure-Object -Property Capacity -Sum

PowerShell - total ram installed

Gathering other memory info

Win32_PhysicalMemory class has tons of properties that you can use to pull from your computer, such as FormFactor, SerialNumber, Speed, etc. You just need to call them up and format them properly. Piping out to Out-GridView is probably the easiest way to get a clean view of what type of RAM you have installed on your computer.

Get-WmiObject Win32_PhysicalMemory -computername C-20141222B | Out-GridView

Putting everything together

And of course, it’s nice if we can put all codes together in a PowerShell format so we can run it easily to get all information at once whether from a local or remote computer. Download the full script below, and run it in a form of:

ram.ps1 -computername remotecomputer

Windows PowerShell - 2015-04-29 16_11_53

Kent Chen

Microsoft MVP, IT Professional, Developer, Geek, and the co-founder of Next of Windows.

Last updated: 01/04/2017

Posted in: Tips & Tricks
Discover more: , ,