Avatar of mikeydk
mikeydk
Flag 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
Powershell

Avatar of undefined
Last Comment
oBdA

8/22/2022 - Mon
Michael Pfister

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
Ganesh Gurudu

try this

$os = Get-Ciminstance Win32_OperatingSystem
$pctFree = [math]::Round(($os.FreePhysicalMemory/$os.TotalVisibleMemorySize)*100,2)
Michael Pfister

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

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
oBdA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.