Lastly, let's look at measuring objects.
Once again, our friendly Get‑Vegetable command,
and I'm going to pipe this to Measure‑Object,
and I'm going to just measure the count property
and get the sum of that property.
So this, in essence,
is telling me how many vegetable objects I have of everything.
So there's 17 individual objects, and then the total of
those all together collectively is 154.
Now that I understand how that command works,
let's try it with some real PowerShell commands.
Let's begin with just a representative object.
Let's do Get‑Process, and let's just grab the first one.
All right, so I can kind of see the property names there.
Really what I should do is probably pipe this to select ‑first 1
and then all property names because the property name I want to
use is not what's listed there.
I'm going to use the WorkingSet property,
and technically I'm going to use the alias WS to do this.
Do Get‑Process, and I'm going to do this for all processes,
and I'm going to measure that WS property,
get the sum, and I'm also going to get the average.
If you look at help, I should say, when you look at help for Measure‑Object,
you'll see the other parameters that are available to you.
And this writes a new object to the pipeline.
So there is the count of the 144 processes,
the average size there of the working set is in bytes,
and then there is the total sum.
Now if I want to, remember, this is just a different type of object.
And if you're curious as to what type of object that is,
you could rerun this command and pipe it to Get‑Member to discover that.
Instead, let's just do this. Let's do Get‑Process,
and we'll measure again the WorkingSet, get the sum and average.
I want a nicer output.
I don't want to see that object that you saw there just above,
so I'm going to Select‑Object and just select the properties I want.
I just want to see the count, the sum, and the average. Now I have an output that's much easier and more appropriate to what I am after.