Get-sqmADGroupMembers Configuration

Lists all members of one or more Active Directory groups. Resolves nested groups recursively. Falls back from Get-ADGroupMember to a direct LDAP query when the ActiveDirectory module is unavailable. Saves TXT and CSV reports per group. Pipeline-capable.

Execution Flow

START ADSI RootDSE connectivity check ADSI OK? throw ERROR NO foreach $group in $GroupName [pipeline] Resolve domain (auto-detect / $Domain param) ActiveDirectory module available? Method 1: ActiveDirectory module Get-ADGroupMember -Recursive → members[] Method 2: LDAP fallback DirectorySearcher → member DNs NO ShouldProcess → write TXT + CSV report Build result: GroupName/MemberCount/Members[]/Status Return $allResults[] DONE

Synopsis

Lists direct and nested members of one or more AD groups. Prefers the ActiveDirectory PowerShell module (Get-ADGroupMember -Recursive) and falls back to a LDAP DirectorySearcher query when the module is unavailable. Writes a formatted TXT and CSV file per group to -OutputPath.

Does not require dbatools. Requires LDAP connectivity to a domain controller (tested via [ADSI]"LDAP://RootDSE" at startup).

Syntax

Get-sqmADGroupMembers
    -GroupName <String[]>    # required, pipeline
    [-Domain <String>]
    [-OutputPath <String>]

Parameters

ParameterTypeDefaultDescription
-GroupNameString[]RequiredAD group name(s). Accepts pipeline input. Format: "GroupName" or "DOMAIN\GroupName".
-DomainStringauto-detectAD domain (e.g. "FITS.LOCAL"). Auto-detected from current domain if not supplied.
-OutputPathStringC:\System\WinSrvLog\MSSQLDirectory for TXT and CSV report files.

Return Value

Array of [PSCustomObject] — one entry per group:

PropertyDescription
GroupNameResolved group name (domain prefix stripped).
DomainAD domain used for the query.
MethodResolution method: Get-ADGroupMember or LDAP-Query.
MemberCountTotal number of members found.
MembersList of members (SamAccountName, DisplayName, ObjectClass).
TxtFilePath to the written TXT report.
CsvFilePath to the written CSV file.
StatusOK (members found) / Warning (no members) / Error.

Examples

# List members of a single group
Get-sqmADGroupMembers -GroupName "DL_SQL_Admins"

# Specify domain explicitly
Get-sqmADGroupMembers -GroupName "Administrators" -Domain "FITS"

# Multiple groups via pipeline
"DL_SQL_Admins","DL_SQL_Readers" | Get-sqmADGroupMembers