Powershell 查询的升序和降序

Ven*_*h R 2 powershell

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

get-command -CommandType cmdlet | Group-Object -Property verb
Run Code Online (Sandbox Code Playgroud)

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

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
Run Code Online (Sandbox Code Playgroud)

请在 PS 中使用单个查询帮助我解决这个问题

Mat*_*sen 5

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

Get-Command -CommandType cmdlet |Group-Object Verb |Sort-Object Count,@{Expression='Name';Descending=$false} -Descending
Run Code Online (Sandbox Code Playgroud)