Original article address:Http://app.en25.com/e/es.aspx? S = 1403 & E = 4571 & elq = 535d59530c004cd899a9c0ff03da88a4
Original article:
Sort-object can sort on multiple properties at the same time. Have a look:
Get-service | sort-object status, name
This will list stopped services first, then running services. within the two blocks, services are sorted by name. to reverse sort order, you can add-descending. then, however, both properties wocould be sorted in descending order. here is how you can specify sort order individually:
$ Prop1 =@{ expression = 'status'; descending = $ true}
$ Prop2 =@ {expression = 'name'; ascending = $ true}
Get-service | sort-object $ prop1, $ prop2
Translation:
Sort-ObjectYou can specify sorting for multiple attributes at the same time, for example:
Get-service | sort-object status, name
This command first lists the stopped services and then lists the running services. In these two groups, the Service list is sorted by service name. If you want to reverse the sorting order, you can add-Descending. In this way, both attributes are sorted in descending order according to the rule. The following is a method for specifying sorting rules:
$ Prop1 =@{ expression = 'status'; descending = $ true}
$ Prop2 =@ {expression = 'name'; ascending = $ true}
Get-service | sort-object $ prop1, $ prop2
Notes:
You can specify sorting rules for a column when defining it.