powershell - 如何正确计算对象集合中的元素数量

标签 powershell

我有以下收藏;

Collection  Property1   Property2
---------------------------------
Coll1       blue        hot
Coll1       red         cold
Coll1       yellow      orange
Coll1       false       false
Coll2       dog         cat
Coll2       out         in
Coll2       house       car
Coll3       yellow      red
Coll3       brick       mortar
Coll3       winter      winter
Coll3       summer      summer
Coll3       ski         snow
Coll3       cyan        brown

如何计算 Coll1 中有多少元素(集合的数量是动态的,因此过滤器也必须是动态的)? 我想我正在寻找诸如有多少元素具有唯一的集合ID

之类的内容

最佳答案

我还没有在 PowerShell 中看到可以输出您在问题中显示的内容的哈希表,但通常方式如下:

Get-Foo | Group-Object Collection -NoElement

关于powershell - 如何正确计算对象集合中的元素数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9756888/

相关文章:

excel - 从多个 CSV 文件构建 Excel 电子表格

c++ - 从头文件 <string> 编译,<stack> 没有给出任何输出

powershell - 如何使用 PowerShell 覆盖文件?

powershell - Hudson 更新到 powershell 3 后找不到 powershell

windows - 如何获取每个文件的创建时间并格式化

powershell - %temp% 等不工作

powershell - 喜欢不同 Powershell 版本上的行为

powershell - 请解释 set-content $zipfilename ("PK"+ [char]5 + [char]6 + ("$([char]0)"* 18)) Powershell 脚本行

powershell - VSTS : Pass build/release variables into Powershell script task

azure - 将 PowerShell 对象数据记录到 Azure blob,因为 CSV 缺少换行符