If I run the following command in PowerShell, it will return to me an object with the sum of the WorkingSet property:
PS > get-process chrome | measure-object WorkingSet -sum
Count : 36
Average :
Sum : 2377129984
Maximum :
Minimum :
Property : WorkingSet
If I want to return just the Sum value, the only way I’ve found to do it is:
PS > $a = get-process chrome | measure-object WorkingSet -sum
PS > $a.Sum
2359980032
Is there a way to pipe the original command to some other command so that I return the integer in a single step? Something like this:
PS > get-process chrome | measure-object WorkingSet -sum | {some other command}
Yes, use Select-Object:
Select-Object is used when one needs only some properties from the original object. It creates a new object and copies the desired properties to the new one.
In case you need to extract the value (from one property), you use parameter
-expandPropertyinstead of-property:Note that you can compute the returned value: