Execution Flow
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
| Parameter | Type | Default | Description |
|---|---|---|---|
| -GroupName | String[] | Required | AD group name(s). Accepts pipeline input. Format: "GroupName" or "DOMAIN\GroupName". |
| -Domain | String | auto-detect | AD domain (e.g. "FITS.LOCAL"). Auto-detected from current domain if not supplied. |
| -OutputPath | String | C:\System\WinSrvLog\MSSQL | Directory for TXT and CSV report files. |
Return Value
Array of [PSCustomObject] — one entry per group:
| Property | Description |
|---|---|
| GroupName | Resolved group name (domain prefix stripped). |
| Domain | AD domain used for the query. |
| Method | Resolution method: Get-ADGroupMember or LDAP-Query. |
| MemberCount | Total number of members found. |
| Members | List of members (SamAccountName, DisplayName, ObjectClass). |
| TxtFile | Path to the written TXT report. |
| CsvFile | Path to the written CSV file. |
| Status | OK (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