传递 Group-Object 属性 以在 PowerShell 中进一步输出

Pass the Group-Object property to further output in PowerShell

如何将 Group-Object 属性 传递给进一步的输出?

使用这个 PowerShell 命令

 $log | Group-Object -Property Date | % { $PSItem.Group | measure -Property Sent,Receive -Sum }

我得到了

Count    : 37269
Average  :
Sum      : 732408700
Maximum  :
Minimum  :
Property : Sent

Count    : 37269
Average  :
Sum      : 212846968
Maximum  :
Minimum  :
Property : Receive

Count    : 27813
Average  :
Sum      : 553072764
Maximum  :
Minimum  :
Property : Sent

Count    : 27813
Average  :
Sum      : 162171286
Maximum  :
Minimum  :
Property : Receive

但我想知道这些值属于哪个组。

$PSItem 有您的 GroupInfo 对象。直接访问Name属性就可以了:

$log | Group-Object -Property Date | % { $PSItem.Name; $PSItem.Group | measure -Property Sent,Receive -Sum }