Forum Discussion
Diego13
Nov 09, 2022Copper Contributor
Get nested AD groups from bulk user or OU
Hi,
I would like to export in a csv file all groups and nested groups from bulk AD user or OU.
Example:
Users | Groups | NestedGroups | |||||||||
User1 | Group1 | NestedGroup1 | NestedGroup2 | NestedGroup3 | |||||||
Group2 | NestedGroup1 | NestedGroup2 | |||||||||
Group3 | NestedGroup1 | NestedGroup2 | NestedGroup3 | NestedGroup4 | NestedGroup5 | NestedGroup6 | NestedGroup7 | NestedGroup8 | NestedGroup9 | NestedGroup10 | |
Group4 | NestedGroup1 | NestedGroup2 | NestedGroup3 | NestedGroup4 | |||||||
Group5 | NestedGroup1 | NestedGroup2 | NestedGroup3 | NestedGroup4 | NestedGroup5 | ||||||
User2 | Group1 | NestedGroup1 | NestedGroup2 | NestedGroup3 | |||||||
Group2 | NestedGroup1 | NestedGroup2 | |||||||||
Group3 | NestedGroup1 | NestedGroup2 | NestedGroup3 | NestedGroup4 | NestedGroup5 | NestedGroup6 | NestedGroup7 | NestedGroup8 | NestedGroup9 | NestedGroup10 | |
Group4 | NestedGroup1 | NestedGroup2 | NestedGroup3 | NestedGroup4 | |||||||
Group5 | NestedGroup1 | NestedGroup2 | NestedGroup3 | NestedGroup4 | NestedGroup5 |
Thanks
- Alan2022Iron Contributor
# Filter Groups in AD based on OU $searchBase = "OU=Test,DC=company,DC=com" Get-ADGroup -Filter * -SearchBase $searchBase -Property * | Sort-Object Name # Get List of Members base on Group Name Get-ADGroupMember -Identity '<GroupName>' -Recursive | Select-Object -Property @{n="Members"; e={ $_.Name }} | Sort-Object Members
- Diego13Copper ContributorHi Alan, thanks for the powershell provided.
Is it possible to export the results as requested please ?