PowerShell for Windows Admins

Sep 8 2013   7:28AM GMT

How much RAM does my machine have?

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

If you need to determine the RAM in a system you can use the Win32_ComputerSystem class

Get-CimInstance -ClassName Win32_ComputerSystem |
select Name, TotalPhysicalMemory

The answer is in bytes BUT it only shows the memory available to the OS. Many systems steal RAM for graphics cards or other devices.

The true amount of physical memory is obtained from the Win32_PhysicalMemory class which gets data in each memory bank in your system. PowerShell will even add them up for you if you ask nicely.

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

If you just need the value:

(Get-WmiObject Win32_PhysicalMemory |
Measure-Object -Property Capacity -Sum).Sum

or

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

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: