Export AD group members

Roger Roger 7,181 Reputation points
2021-07-27T04:25:22.163+00:00

Hi All

i have an AD group and it has nested AD groups i want to export all the members of the AD groups including the members of nested AD groups. when i use the below syntax i am not getting the users in the nested AD groups.

Get-ADGroupMember -Identity "MyADGroup" -Recursive | Get-ADUser -Properties Title,physicalDeliveryOfficeName,office,Department | Select Name,UserprincipalName,physicalDeliveryOfficeName,Office,Title,Department,SamAccountName,DistinguishedName | Export-CSV -Path C:\output.csv -NoTypeInformation

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | Other
{count} votes

Accepted answer
  1. Anonymous
    2021-07-28T03:08:08.777+00:00

    Hi @Roger Roger ,

    The Get-ADGroupMember cmdlet will pull the member users of the nested groups as well when the "-Recursive" switch is used.

    -Recursive
    Specifies that the cmdlet get all members in the hierarchy of a group that do not contain child objects.

    The below help document can be helpful.
    https://learn.microsoft.com/en-us/powershell/module/activedirectory/get-adgroupmember

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Roger Roger 7,181 Reputation points
    2021-07-27T13:30:03.24+00:00

    i am able to pull the users, but i am not sure the AD group has nested AD groups will it pull all the users from those Nested AD groups.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.