Audit Active Directory Privileged Group Membership
Before you begin
- Applies to:Read-only review of selected privileged groups across one Active Directory forest.
- Where to start:Open PowerShell with the Active Directory module on an approved administration workstation.
- What you need:Have read access in every included domain, connectivity to their AD Web Services, and a protected location for the export.
Guide tools
Privileged groups grant broad control over domain identities, systems, and policy. A periodic membership review helps identify stale access, unexpected nested groups, and accounts that need owner confirmation.
This walkthrough reads every domain in one AD forest and exports a dated snapshot of direct membership in each domain’s Domain Admins and Builtin Administrators groups, plus the forest-root Enterprise Admins and Schema Admins groups. Run it from an approved administrative workstation with the Active Directory PowerShell module, network access to each domain’s AD Web Services, and read permissions in every domain. It does not include local machine administrators or Microsoft Entra roles.
Check the Read-Only Audit Context
Audit SetupLoad the Active Directory module and list the forest root and all domains in scope. Keep this PowerShell session open because the following steps reuse its forest, group, and report variables. The script queries each domain explicitly; access failures stop the audit and must be resolved before treating the export as forest-wide.
Import-Module ActiveDirectory -ErrorAction Stop$forest = Get-ADForest -ErrorAction Stop$forest | Select-Object RootDomain, Domains$domains = foreach ($dnsName in $forest.Domains) { Get-ADDomain -Identity $dnsName -ErrorAction Stop}$domains | Select-Object DNSRoot, DistinguishedName, PDCEmulator❯ Illustrative Output (Results Vary)
RootDomain : corp.exampleDomains : {corp.example, emea.corp.example}
DNSRoot : corp.exampleDNSRoot : emea.corp.exampleDefine the Review Set for Your Forest
Privileged AccessUse each built-in group’s well-known SID rather than its display name, which can be localized or renamed. Domain Admins exists in every domain; Enterprise Admins and Schema Admins are forest-root groups. The Builtin Administrators SID is queried separately in each domain.
$root = Get-ADDomain -Identity $forest.RootDomain -ErrorAction Stop$targets = foreach ($domain in $domains) { [pscustomobject]@{ Domain = $domain.DNSRoot; Name = 'Domain Admins'; SID = "$($domain.DomainSID.Value)-512" } [pscustomobject]@{ Domain = $domain.DNSRoot; Name = 'Builtin Administrators'; SID = 'S-1-5-32-544' }}$targets += [pscustomobject]@{ Domain = $root.DNSRoot; Name = 'Enterprise Admins'; SID = "$($root.DomainSID.Value)-519" }$targets += [pscustomobject]@{ Domain = $root.DNSRoot; Name = 'Schema Admins'; SID = "$($root.DomainSID.Value)-518" }
$groups = foreach ($target in $targets) { try { $group = Get-ADGroup -Identity $target.SID -Server $target.Domain -Properties Description -ErrorAction Stop [pscustomobject]@{ Domain = $target.Domain; Name = $target.Name; Group = $group } } catch { throw "Could not query $($target.Name) in $($target.Domain): $($_.Exception.Message)" }}$groups | Select-Object Domain, Name, @{Name='SID'; Expression={$_.Group.SID.Value}}, @{Name='Description'; Expression={$_.Group.Description}}❯ Illustrative Output (Results Vary)
Domain Name SID Description------ ---- --- -----------corp.example Domain Admins S-1-5-21-...-512 ...emea.corp.example Domain Admins S-1-5-21-...-512 ...corp.example Enterprise Admins S-1-5-21-...-519 ...Capture Member and Nested-Group Details
Evidence SnapshotExport direct membership first so nested groups remain visible as separate review items. The domain column identifies where each group was queried. Resolve each member to capture its object class, distinguished name, and SID, then include the group identity in the same report.
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'$report = Join-Path $PWD "privileged-group-members-$stamp-$([guid]::NewGuid().ToString('N')).csv"$rows = foreach ($entry in $groups) { $members = @(Get-ADGroupMember -Identity $entry.Group -Server $entry.Domain -ErrorAction Stop) if ($members.Count -eq 0) { [pscustomobject]@{ Domain = $entry.Domain GroupName = $entry.Name GroupSID = $entry.Group.SID.Value MemberName = '[no direct members]' MemberType = 'NoDirectMembers' MemberDN = $null MemberSID = $null } continue } foreach ($member in $members) { $memberSid = if ($member.SID) { $member.SID.Value } else { $null } [pscustomobject]@{ Domain = $entry.Domain GroupName = $entry.Name GroupSID = $entry.Group.SID.Value MemberName = $member.Name MemberType = $member.objectClass MemberDN = $member.DistinguishedName MemberSID = $memberSid } }}$rows | Sort-Object Domain, GroupName, MemberName | Export-Csv -NoTypeInformation -Encoding UTF8 -NoClobber -ErrorAction Stop -Path $report$report❯ Illustrative Output (Results Vary)
D:\Audit\privileged-group-members-20261004-101500-71e85e84742b4c14a03097e2b7a41f61.csvAssign Owners to Access Decisions
ReviewHave the relevant service or directory owners confirm each member’s purpose and approval. Check nested groups recursively as a separate analysis so the report preserves both direct assignments and their effective membership paths. Resolve any query error from Step 2 and rerun the audit before reviewing the export; a failed query stops report generation rather than producing a partial forest result.
$reportRows = @(Import-Csv -LiteralPath $report -ErrorAction Stop)$reportRows | Group-Object Domain, GroupName | ForEach-Object { [pscustomobject]@{ Group = $_.Name DirectMemberCount = @($_.Group | Where-Object MemberSID).Count }}Get-FileHash -LiteralPath $report -Algorithm SHA256 -ErrorAction Stop❯ Illustrative Output (Results Vary)
Group DirectMemberCount----- ------------------corp.example, Domain Admins 12corp.example, Builtin Administrators 0corp.example, Enterprise Admins 3
Algorithm : SHA256Hash : ...Your feedback keeps these production procedures accurate and battle-tested.