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

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

  • Author
    Posts
  • #67830

    Jeff Taylor
    Participant

    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

  • #67833

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

    Jeff Taylor
    Participant

    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.