I have following result while running below powershell command,
PS C:\> Get-Process svchost
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
546 34 18528 14884 136 49.76 260 svchost
357 14 4856 4396 47 18.05 600 svchost
314 17 6088 5388 42 12.62 676 svchost
329 17 10044 8780 50 12.98 764 svchost
1515 49 36104 38980 454 232.04 812 svchost
301 33 9736 6428 54 2.90 832 svchost
328 26 8844 9744 52 4.32 856 svchost
247 18 8144 9912 77 37.50 904 svchost
46 5 1504 968 14 0.02 1512 svchost
278 15 4048 5660 43 3.88 2148 svchost
98 14 2536 2460 35 0.66 2504 svchost
Here im trying to calculte the total memory size PM(K)
of process(s).i've following line in my ps1 script file
get-process svchost | foreach {$mem=("{0:N2}MB " -f ($_.pm/1mb))}
It gives the output in the following format
17.58MB 4.79MB 6.05MB 9.99MB 35.29MB 9.56MB 8.64MB 7.95MB 1.47MB 3.95MB 2.48MB
but i need total size as a single value like 107.75MB
How to calculate the total used memory size of svchost
process ?
Thanks
You can use the Measure-Object cmdlet
$measure = Get-Process svchost | Measure-Object PM -Sum
$mem = ("{0:N2}MB " -f ($measure.sum / 1mb))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With