2015-01-09 27 views
0

我有码取阵列​​和显示器(1)的含量NAME(2)发生次数的该内容ValuePowershell的排序散列表基于计数

$iis_stats | group | % { $h = @{} } { $h[$_.Name] = $_.Count } {$h} 

如何通过值做我排序$ H在降序排列并打印出来?

我试图

$h | sort-object @{Expression={$_[1]}; Ascending=$false} {$h} 

我得到错误:

Sort-Object : A positional parameter cannot be found that accepts argument '$h'. 
At D:\Script\parse_IIS_logs.ps1:45 char:6 
+ $h | sort-object @{Expression={$_[1]}; Ascending=$false} {$h} 
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : InvalidArgument: (:) [Sort-Object], ParameterBindingException 
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SortObjectCommand 

如何解决?

回答

1

是否这样?

$h.getenumerator() | sort value -descending