Where-Object -like Get-ADGroupMember "name" or "CN"

I have this one-liner:

Get-ADGroup -Identity ‘L3-GROUP’ -Credential $creds -Properties * | select members -ExpandProperty members

…but want to search within that result set and filter for a particular string, but since my pipeline is now just a single NoteProperty “member”, how do I find my string pattern?

I like expandProperty on members but not what it throws away in the process.


(Get-ADGroup -Identity 'L3-GROUP' -Credential $creds -Properties *).members -match 'mystring'

Thanks Sam! That’s a one-liner of utter elegance and beauty. My colleague helped me with this one as well:

Get-ADGroup -Identity 'L3-GROUP' -Credential $creds -Properties * `
| select -expandproperty members | where-object  { $_ -match "mystring"}