I need help in finding the physical memory usage property in Get-Process cmdlet. I have read searched on google and found that WS(K) is used to find usage for physical memory. I am referring to ‘Memory’ tab on Task Manager. I have tried WS(K) but found different usage in task manager and in powershell property for WS(K). Please confirm what is the exact properly to check physical RAM usage. Or am I doing something wrong?
Please let me know if you need any further information.
PS C:\Windows> get-process | get-member |? Name -like '*memory*'
TypeName: System.Diagnostics.Process
Name MemberType Definition
---- ---------- ----------
NonpagedSystemMemorySize Property int NonpagedSystemMemorySize {get;}
NonpagedSystemMemorySize64 Property long NonpagedSystemMemorySize64 {get;}
PagedMemorySize Property int PagedMemorySize {get;}
PagedMemorySize64 Property long PagedMemorySize64 {get;}
PagedSystemMemorySize Property int PagedSystemMemorySize {get;}
PagedSystemMemorySize64 Property long PagedSystemMemorySize64 {get;}
PeakPagedMemorySize Property int PeakPagedMemorySize {get;}
PeakPagedMemorySize64 Property long PeakPagedMemorySize64 {get;}
PeakVirtualMemorySize Property int PeakVirtualMemorySize {get;}
PeakVirtualMemorySize64 Property long PeakVirtualMemorySize64 {get;}
PrivateMemorySize Property int PrivateMemorySize {get;}
PrivateMemorySize64 Property long PrivateMemorySize64 {get;}
VirtualMemorySize Property int VirtualMemorySize {get;}
VirtualMemorySize64 Property long VirtualMemorySize64 {get;}
These are the memory properties you have to pick from. I couldn’t tell you for sure which is the “physical” ram usage, and honestly that metric may not even be particularly useful. Do note that they will be in bytes, unlike workingset which is a calculated property. Divide them by 1kb to get the same numbers you’d expect to see in Task Manager. I’m not sure which metric Task Manager uses by default.
Thanks for providing this information however I am already aware of this information. I am asking this because on daily basis, we get the alert as “‘Servername’ - Available Megabytes of Memory is too low”. Usually I check the server manually and it shows which process is consuming the most of the memory (Again I am referring to ‘Memory’ tab on Task Manager). But I want to check it from PS, I can convert the bytes in MB. Or could you tell me any other alternate to check memory usage from PS that refers to ‘Memory’ tab in task manager.
The Windows Task manager is a live feed, it’s like running your script in a loop checking memory every couple seconds, which fluctuates based on what the system is doing. The script is static, basically getting a snapshot of when it runs one time. The Get-Process or WMI Win32_Process will provide you the current memory statistics when the script is executed, but it is unlikely that it will match the Task Manager or Perfmon unless the system is idle.