Export AD group membership

skip hofmann 1 Reputation point
2022-11-08T17:39:48.127+00:00

The accepted answer at https://learn.microsoft.com/en-us/answers/questions/980667/export-ad-group.html is exactly what i need, however i need it to export to just 1 .csv file, and also export the nested groups. Any help is greatly appreciated

Windows for business | Windows Server | User experience | PowerShell
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2022-11-10T15:42:00.373+00:00

    To get the group membership and the groups to which members belong might require the use of recursive code. It would also require you to take into account that groups may be members of multiple groups and those groups may be members of groups you've already processes -- so you'd have to keep track of what's already been processed and avoid processing it again to avoid an endless loop.

    There are many examples that use PowerShell to give you a hierarchical list of group memberships. Start by searching for "powershell group membership recurse".

    I'm not sure I understand your example of the CSV though. Are user2, user4, user3, and user5 members of groupC or groupA? Is groupB a member of groupA or groupC?

    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.