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

Welcome Forums General PowerShell Q&A Where-Object -like Get-ADGroupMember "name" or "CN"

This topic contains 2 replies, has 2 voices, and was last updated by

1 year, 11 months ago.

  • Author
  • #67830

    Points: 71
    Rank: Member

    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

    Points: 246
    Helping Hand
    Rank: Participant
    (Get-ADGroup -Identity 'L3-GROUP' -Credential $creds -Properties *).members -match 'mystring'
  • #67834

    Points: 71
    Rank: Member

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

The topic ‘Where-Object -like Get-ADGroupMember "name" or "CN"’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort