Report · 1 tool
Export nested group membership
Summary
Expands every nested group to list the real users who get access through a group, including the path they inherit it through. Essential before migrating groups or file share permissions.
Implementation
Choose your tool. Your choice is remembered on other samples.
Import-Module ActiveDirectory
function Expand-Group($group, $path) {
foreach ($m in Get-ADGroupMember -Identity $group) {
if ($m.objectClass -eq "group") { Expand-Group $m.DistinguishedName "$path > $($m.Name)" }
else { [pscustomobject]@{ User = $m.SamAccountName; Name = $m.Name; Type = $m.objectClass; Via = $path } }
}
}
$root = "Finance-Share-Modify"
Expand-Group $root $root | Sort-Object User -Unique |
Export-Csv ".\$root-members.csv" -NoTypeInformationPrerequisites
- RSAT ActiveDirectory module
Output
CSV of users with the group they were found through.
Contributors
| Author | Role |
|---|---|
| Priyanshu Upadhyay | Solution Architect, Microsoft 365 and Azure |
InnovaticT