2015-05-19 42 views
0

我有一个名为$ listy的对象数组。 我找对象,其属性$ _ WorkflowAssociations.Count大于0在Powershell中筛选

当我选择属性,我可以看到几个对象符合我的标准。

$listy | select title, workflowassociations.count 

然而,当我使用其中:$listy | where {$_.WorkflowAssociations.Count -gt 0}任何对象都列: enter image description here

我有同样的问题与$ _ Views.Count财产。其他数字属性似乎过滤没有问题。是否因为(。)点?为什么?该属性称为恰好Views.Count: enter image description here

+3

试试'$ _。“WorkflowAssociations.Count”'? –

+1

请将您的终端输出作为文本(格式化为代码)而不是屏幕捕获的图像。通读是一项相当艰巨的任务。 –

回答

2

正如@EtanReisner已经在评论你的问题指出:如果你有一个包含点的属性名称(如WorkflowAssociations.Count),你必须引号名称当试图通过点符号访问它:

$listy | Where-Object { $_.'WorkflowAssociations.Count' -gt 0 } 

如果你不这样做,术语$_.WorkflowAssociations.Count将被解释为当前对象($_)的属性WorkflowAssociation的财产Count。当然,这不存在。