1
00:00:01,040 --> 00:00:04,100
Lastly, let's look at measuring objects.

2
00:00:04,100 --> 00:00:06,890
Once again, our friendly Get‑Vegetable command,

3
00:00:06,890 --> 00:00:10,090
and I'm going to pipe this to Measure‑Object,

4
00:00:10,090 --> 00:00:12,780
and I'm going to just measure the count property

5
00:00:12,780 --> 00:00:16,840
and get the sum of that property.

6
00:00:16,840 --> 00:00:17,940
So this, in essence,

7
00:00:17,940 --> 00:00:22,980
is telling me how many vegetable objects I have of everything.

8
00:00:22,980 --> 00:00:27,460
So there's 17 individual objects, and then the total of

9
00:00:27,460 --> 00:00:33,140
those all together collectively is 154.

10
00:00:33,140 --> 00:00:36,420
Now that I understand how that command works,

11
00:00:36,420 --> 00:00:39,440
let's try it with some real PowerShell commands.

12
00:00:39,440 --> 00:00:42,430
Let's begin with just a representative object.

13
00:00:42,430 --> 00:00:45,840
Let's do Get‑Process, and let's just grab the first one.

14
00:00:45,840 --> 00:00:48,430
All right, so I can kind of see the property names there.

15
00:00:48,430 --> 00:00:51,500
Really what I should do is probably pipe this to select ‑first 1

16
00:00:51,500 --> 00:00:56,040
and then all property names because the property name I want to

17
00:00:56,040 --> 00:00:58,410
use is not what's listed there.

18
00:00:58,410 --> 00:01:01,170
I'm going to use the WorkingSet property,

19
00:01:01,170 --> 00:01:05,540
and technically I'm going to use the alias WS to do this.

20
00:01:05,540 --> 00:01:09,740
Do Get‑Process, and I'm going to do this for all processes,

21
00:01:09,740 --> 00:01:13,640
and I'm going to measure that WS property,

22
00:01:13,640 --> 00:01:17,470
get the sum, and I'm also going to get the average.

23
00:01:17,470 --> 00:01:20,660
If you look at help, I should say, when you look at help for Measure‑Object,

24
00:01:20,660 --> 00:01:25,540
you'll see the other parameters that are available to you.

25
00:01:25,540 --> 00:01:28,740
And this writes a new object to the pipeline.

26
00:01:28,740 --> 00:01:32,780
So there is the count of the 144 processes,

27
00:01:32,780 --> 00:01:36,820
the average size there of the working set is in bytes,

28
00:01:36,820 --> 00:01:39,640
and then there is the total sum.

29
00:01:39,640 --> 00:01:42,980
Now if I want to, remember, this is just a different type of object.

30
00:01:42,980 --> 00:01:45,420
And if you're curious as to what type of object that is,

31
00:01:45,420 --> 00:01:50,240
you could rerun this command and pipe it to Get‑Member to discover that.

32
00:01:50,240 --> 00:01:53,440
Instead, let's just do this. Let's do Get‑Process,

33
00:01:53,440 --> 00:01:59,540
and we'll measure again the WorkingSet, get the sum and average.

34
00:01:59,540 --> 00:02:01,960
I want a nicer output.

35
00:02:01,960 --> 00:02:05,680
I don't want to see that object that you saw there just above,

36
00:02:05,680 --> 00:02:09,240
so I'm going to Select‑Object and just select the properties I want.

37
00:02:09,240 --> 00:02:20,000
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.

