Author Posts

April 3, 2017 at 10:22 pm

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.

thanks

April 3, 2017 at 10:43 pm

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

April 3, 2017 at 11:10 pm

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"}