Powershell查询的升序和降序

时间:2018-06-10 15:26:55

标签: powershell

下面的查询将列出power shell中的cmdlet。

get-command -CommandType cmdlet | Group-Object -Property verb

因为我需要按降序对列计数进行排序,然后按升序命名列。以下查询未给出预期结果。

get-command -CommandType cmdlet | Group-Object -Property verb | Sort-Object Count, name -Descending
get-command -CommandType cmdlet | Group-Object -Property verb | Sort-Object Count -Descending | Sort-Object name
get-command -CommandType cmdlet | Group-Object -Property verb | Sort-Object Count -Descending,  name

请用PS中的单个查询帮助我

1 个答案:

答案 0 :(得分:4)

您可以通过提供带有Descending项的哈希表来覆盖单个属性的顺序:

Get-Command -CommandType cmdlet |Group-Object Verb |Sort-Object Count,@{Expression='Name';Descending=$false} -Descending