Sort‑Object needs a property name so it knows what to sort on.
Now you can use any object property that you see with Get‑Member.
Remember,
don't assume the default output for a command is showing you all of the
property names or even the correct property names.
Pipe a command to Get‑Member to discover all of the
correct and valid property names.
Now it is possible to sort on a custom property that you
can define on the fly, but that's a bit out of the scope
of this course. By the way, the sort order is in ascending order,
but there is a ‑descending parameter you can use if you want to reverse
that. Sort‑Object takes all of the incoming objects,
sorts them on the property that you specify, and then writes that
sorted list of objects back to the pipeline.
So in this example,
that would be services. Group‑Object follows a similar pattern.
You'll typically pipe the results of one command into Group‑Object.
Now this too requires you to specify a property name,
and as you gain experience,
you'll learn how create, again, custom or new properties on the fly
that you can group on. Now for the fun part. Group‑Object writes a
new type of object to the pipeline.
This object has properties that display the group's property name,
the number of matching items, and a collection of all those items
that belong to that group, the source objects,
in other words.
So in this example, that would be services. The services
that we got in the first command from Get‑Service, they're
not written to the pipeline.
Instead,
you get this custom, or should say new, object. So the service objects are
contained in the corresponding Group‑Object. And this will make a lot more sense in the demo when you can see this in action.