I have a PowerShell object and I want to filter the results.
public Collection<PSObject> Groups;
I have successfully achieved this using linq if I need to filter based on a direct member. But what if I want to filter based on an object 1 or 2 levels deep?
Here is the linq query to filter on a direct member:
var groupMembershipFilter = (dynamic)CsQ.Groups.Where(x => x.Members["AgentsByUri"].Value != null).ToList();
However I need to drill down another level. In PowerShell this would be easy:
$x.AgentsByUri.AbsoluteUri
I have tried all sorts but cant figure out how to make this work. So that you can better understand the object structure here are a couple of screen shots:
From the above screen shots you can see the "AgentsByUri" is a collection. Inside that collection I want to test if the property "AbsoluteUri" contains a certain string value.
The other thing I dont understand is why I have to use "Members" and cant just use "BaseObject" - this structure look far more similar to PowerShell and would be my preference if possible as it translates better to my PowerShell brain.
Excuse my terminology, I'm reasonably new to C#! Hopefully this makes sense :)
Any help or guidance would be much appreciated.


