From the course: PowerShell 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Sorting the information

Sorting the information - PowerShell Tutorial

From the course: PowerShell 5 Essential Training

Start my 1-month free trial

Sorting the information

- Often times when working with objects, I also wanna sort them. I not only want to grab specific information about them but then I wanna sort that information. So, let's start off with get-service, and I want all of the services. I want to just select the properties of the name of the service, and its current status. But, here's what's happening. When I hit Enter, it's giving the list. Look at how it's sorting them. It's not sorting them on status, it's sorting them on, well, look, it's sorting them on the name of the service, alphabetically. I don't actually want that. What I'd rather have, is I'd rather have it sorted on the status, and show me the Running ones, then show me the Stopped ones. Well, here's the best part. I now wanna sort them, and we have a cmdlet called Sort-Object. And you sort by Property. So, it's working the way that my brain is thinking about this. Select name and status, and I'd like to sort on the property, while I want to sort on status. And let's test this…

Contents