1
00:00:01,040 --> 00:00:04,740
Sort‑Object needs a property name so it knows what to sort on.

2
00:00:04,740 --> 00:00:08,670
Now you can use any object property that you see with Get‑Member.

3
00:00:08,670 --> 00:00:09,130
Remember,

4
00:00:09,130 --> 00:00:13,040
don't assume the default output for a command is showing you all of the

5
00:00:13,040 --> 00:00:16,040
property names or even the correct property names.

6
00:00:16,040 --> 00:00:19,300
Pipe a command to Get‑Member to discover all of the

7
00:00:19,300 --> 00:00:22,140
correct and valid property names.

8
00:00:22,140 --> 00:00:25,060
Now it is possible to sort on a custom property that you

9
00:00:25,060 --> 00:00:27,690
can define on the fly, but that's a bit out of the scope

10
00:00:27,690 --> 00:00:32,090
of this course. By the way, the sort order is in ascending order,

11
00:00:32,090 --> 00:00:35,560
but there is a ‑descending parameter you can use if you want to reverse

12
00:00:35,560 --> 00:00:39,900
that. Sort‑Object takes all of the incoming objects,

13
00:00:39,900 --> 00:00:43,370
sorts them on the property that you specify, and then writes that

14
00:00:43,370 --> 00:00:46,340
sorted list of objects back to the pipeline.

15
00:00:46,340 --> 00:00:47,400
So in this example,

16
00:00:47,400 --> 00:00:51,640
that would be services. Group‑Object follows a similar pattern.

17
00:00:51,640 --> 00:00:56,240
You'll typically pipe the results of one command into Group‑Object.

18
00:00:56,240 --> 00:00:59,270
Now this too requires you to specify a property name,

19
00:00:59,270 --> 00:01:00,570
and as you gain experience,

20
00:01:00,570 --> 00:01:04,050
you'll learn how create, again, custom or new properties on the fly

21
00:01:04,050 --> 00:01:08,170
that you can group on. Now for the fun part. Group‑Object writes a

22
00:01:08,170 --> 00:01:10,840
new type of object to the pipeline.

23
00:01:10,840 --> 00:01:15,020
This object has properties that display the group's property name,

24
00:01:15,020 --> 00:01:18,910
the number of matching items, and a collection of all those items

25
00:01:18,910 --> 00:01:21,800
that belong to that group, the source objects,

26
00:01:21,800 --> 00:01:22,660
in other words.

27
00:01:22,660 --> 00:01:26,480
So in this example, that would be services. The services

28
00:01:26,480 --> 00:01:29,080
that we got in the first command from Get‑Service, they're

29
00:01:29,080 --> 00:01:30,300
not written to the pipeline.

30
00:01:30,300 --> 00:01:30,600
Instead,

31
00:01:30,600 --> 00:01:35,870
you get this custom, or should say new, object. So the service objects are

32
00:01:35,870 --> 00:01:43,000
contained in the corresponding Group‑Object. And this will make a lot more sense in the demo when you can see this in action.

