Need script on getting the RAM details

Hi Fellas,

I need to extract the RAM details in a formatted csv file.

I am using this

function RAMINFO{
$memory = (get-Counter -ListSet memory).paths
Get-Counter -Counter $memory -SampleInterval 1

This shows me all the counters… I need just the basic ones ( the ones that shows on the task manager console - Commit, In Use, pages, Total, Non Paged)
Can someone help me extracting the details in a CSV…

You can have a look at wmi classes win32_physicalmemory. Use Get-CimInstance cmdlet to explore the class.

I have checked the details from the class but not getting an option of getting the details like Paged Memory, Non Paged Memory, In Use, Commit Memory
I need these in a csv format with appropriate headings.

If you have a script, please share

If you want information on both physical and virtual memory you’ll have to collect it from multiple places. Virtual memory is a logical device for the operating system (as opposed to a physical device). You can get details on the pagefile from the Win32_PageFileUsage class and use Select-Object to get specific pieces, such as:

Get-CimInstance Win32_PageFileUsage | Select-Object CurrentUsage

To get your CSV, you could collect the specific pieces of information that you want, store them in a custom object with the labels that you want, and then use Export-Csv.