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

This topic contains 2 replies, has 2 voices, and was last updated by  Jeff Taylor 1 year, 2 months ago.

  • Author
  • #67830

    Jeff Taylor

    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.


  • #67833

    Sam Boutros
    (Get-ADGroup -Identity 'L3-GROUP' -Credential $creds -Properties *).members -match 'mystring'
  • #67834

    Jeff Taylor

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

You must be logged in to reply to this topic.