Get-ADGroup CN and Members

Welcome Forums General PowerShell Q&A Get-ADGroup CN and Members

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

4 years, 10 months ago.

  • Author
  • #15713

    Points: 0
    Rank: Member


    I have this command that gets all groups with "SiteAdmins" in the group name and selects its CN and Members:
    Get-ADGroup -searchbase "DC=contoso,DC=com" -filter {name -like "*SiteAdmins*"} -Properties * |
    Select-Object CanonicalName,Members | Format-Table -Wrap

    However, on the "Members" column, I get the names on a distinguished name (DN) format:
    (for example: {CN=Smith\, John,OU=Delegation,DC=contoso,DC=com}).

    How do I get the "Members" column to show the display name instead (Smith, John)?

    Thanks in advance!

  • #15714

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    The Members property contains DNs; you'd need to take those and look up the user objects.

  • #15715

    Points: 2
    Rank: Member

    It might work better to just pipe Get-ADGroup to Get-ADGroupMember:

    Get-ADGroup -searchbase “DC=contoso,DC=com” -filter {name -like “*SiteAdmins*”} | Get-ADGroupMember | Select Name

The topic ‘Get-ADGroup CN and Members’ is closed to new replies.

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