Link to home
Start Free TrialLog in
Avatar of mikeydk
mikeydkFlag for Denmark

asked on

Return memory usage / powershell

Hey

How do I return memory usage on a specific process?

$proc = Get-WmiObject -class win32_process -computer fvrrd06 | where-object {$_.Commandline -eq 'C:\Windows\System32\svchost.exe -k termsvcs' }

I do not see (any properties) the same memory usage as in task manager.

Why
Avatar of Michael Pfister
Michael Pfister
Flag of Germany image

The value shown in task manager is WorkingSetPrivate which can be retrieved via WMI class Win32_PerfRawData_PerfProc_Process

value in task manager = WorkingSetPrivate / 1024

HTH
Avatar of Ganesh Gurudu
Ganesh Gurudu

try this

$os = Get-Ciminstance Win32_OperatingSystem
$pctFree = [math]::Round(($os.FreePhysicalMemory/$os.TotalVisibleMemorySize)*100,2)
Can't see the command line property in this class, you may have to grab the process id from WIn32_Process and query Win32_PerfRawData_PerfProc_Process for the memory


$proc = Get-WmiObject -class win32_process -computer fvrrd06 | where-object {$_.Commandline -eq 'C:\Windows\System32\svchost.exe -k termsvcs' }
$memory =  (Get-WmiObject -class Win32_PerfRawData_PerfProc_Process -computer | where-object {$_.IDProcess -eq $proc.ProcessID}).WorkingSetPrivate 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial