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 systems 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 on 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 a 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

The 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 clear 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 easily run it 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

What to do when security policy prevents the script from running?

When you see the security warning that prevents the script from running, open an elevated PowerShell Window and run the following and give it an “Y” answer.


PowerShell - Set-SecurityPolicy



    • I don’t think so. The computername switch doesn’t read a text file that contains a list of computer names. However, I believe you can change the script to read and loop through the list.

  1. Thanks for the article! FYI, some of the commands have a dash for the WMI class when they should have an underscore (Win32-PhysicalMemory when it should be Win32_PhysicalMemory)

  2. Thanks a lot for blogging, Kent. Typo alert, in some examples you have a dash in “Win32-PhysicalMemory” instead of the correct underscore, “Win32_PhysicalMemory”

  3. Hi thanks for the post.

    I’d be a bit careful as I’m not sure that the MaxCapacity of the Win32_PhysicalMemoryArray class is reliable. I just checked this and it reports 32GB but the quickspecs for my HP report 64GB (and the machine currently has 40GB installed).

    We thought this might be a nice thing to add to our server audit product but it’s looking like the WMI (or more likely the information provided by SMBIOS) is a bit sketchy.


Please enter your comment!
Please enter your name here