'How do I extract a JSON value if another value is higher than zero?

My current code:

Powershell -Noprofile "(Get-Content 'allacts.txt' | ConvertFrom-Json).activityid | Out-File -FilePath ids%filenum%.txt"

This queries the JSON file (allacts.txt) and extracts a single value, activityid.

However, I don't want all the activityids, just the ones where the value attendedpeoplecount is higher than 0. How can I work that if logic into this command?

Sample:

[
  {
    "activityid": 610228,
    "attendedpeoplecount": 0
  },
  {
    "activityid": 568168,
    "attendedpeoplecount": 36
  }
]

Current command on the above json would return

610228
568168

The desired output would be

568168


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source