按对象分组并计算powershell中的每个唯一事件

时间:2014-05-12 12:24:20

标签: powershell window

按“指定团队”分组

echo $var | Group-Object -property "Assigned Team"

INPUT -

PS C:\Users\Bharath> echo $var

Assigned Team
--------------
Database Administration Team
Email Applications Team
Unix Administration Team
Storage Administration Team
Windows Administration Team
Email Applications Team
TSO Senior Manager Team
Advance Digital Team
Network Administration Team
Network Administration Team
Unix Administration Team
Network Administration Team
Network Administration Team
Network Administration Team
Network Administration Team
Network Administration Team
Email Applications Team
Unix Administration Team
Network Administration Team
Network Administration Team
Network Administration Team
Windows Administration Team
Network Administration Team
Network Administration Team
Database Administration Team
Email Applications Team
Network Administration Team
Network Administration Team
Network Administration Team
Network Administration Team
Network Administration Team
IP Voice and Video Team
IP Voice and Video Team
Network Administration Team
Network Administration Team
Network Administration Team
Network Administration Team
Network Administration Team
IP Voice and Video Team
IP Voice and Video Team
IP Voice and Video Team
IP Voice and Video Team
Network Administration Team
Network Administration Team
Email Applications Team
Network Administration Team
Network Administration Team
Network Administration Team
Network Administration Team
Network Administration Team
Unix Administration Team
Network Administration Team
Network Administration Team

INPUT -

PS C:\Users\Bharath> echo $var | group

Count Name                      Group
----- ----                      -----
    1 Microsoft.PowerShell.C...{Microsoft.PowerShell.Commands.Internal.Format.FormatStartData}
    1 Microsoft.PowerShell.C...{Microsoft.PowerShell.Commands.Internal.Format.GroupStartData}
  212 Microsoft.PowerShell.C... {Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData, Microsoft.PowerShell...
    1 Microsoft.PowerShell.C... {Microsoft.PowerShell.Commands.Internal.Format.GroupEndData}
    1 Microsoft.PowerShell.C... {Microsoft.PowerShell.Commands.Internal.Format.FormatEndData}

PS C:\Users\Bharath> $var.gettype()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]                                 System.Array

1 个答案:

答案 0 :(得分:0)

显然,$ var包含格式化对象。命令结果:

foo | format-table 'Assigned Team'

......或其他任何相关的东西。

如果您需要对对象进行分组/排序/过滤,则应避免使用

Format-*