2015-05-19 68 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。當然,這不存在。