0

I have an array of objects called $listy. I am looking for object for which property $_.WorkflowAssociations.Count is greater than 0.

When I select that property I can see that several objects fulfill my criteria:

$listy | select title, workflowassociations.count

However when I use where: $listy | where {$_.WorkflowAssociations.Count -gt 0} none of the objects are listed: enter image description here

I have the same issue with $_.Views.Count property. Other numeric properties seem to filter without issues. Is it because of the point (.)? Why? The property is called exactly Views.Count: enter image description here

2
  • 3
    Try $_."WorkflowAssociations.Count"? Commented May 19, 2015 at 16:08
  • 1
    Please post your terminal output as text (formatted as code) rather than screen captured image. It is quite a task to read through. Commented May 19, 2015 at 16:19

1 Answer 1

2

As @EtanReisner already pointed out in the comments to your question: if you have a property name containing a dot (like WorkflowAssociations.Count) you must put the name in quotes when trying to access it via dot notation:

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

If you don't, the term $_.WorkflowAssociations.Count will be interpreted as the property Count of a property WorkflowAssociation of the current object ($_). Which, of course, doesn't exist.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.