Background
A quick follow-up to one of our last posts.
In the past, we used Get-ADGroupMember to fetch group members.
But, occasionally we ran into an error message.
Lineage
- PowerShell:- Get-ADGroupMember – Member Count
Published:- 2024-June-19th
Link
Error Message
In our environment, here is the error received when we issued “Get-ADGroupMember” against “Domain Users“:-
>powershell -command "$objADGroupMember = Get-ADGroupMember -Identity 'Domain Users'; if ( $null -ne $objADGroupMember ){ $objADGroupMember.Count }" Get-ADGroupMember : The size limit for this request was exceeded At line:1 char:21 + ... oupMember = Get-ADGroupMember -Identity 'Domain Users' -Recursive; if ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (Domain Users:ADGroup) [Get-ADGroupMember], ADException + FullyQualifiedErrorId : ActiveDirectoryServer:8227,Microsoft.ActiveDirectory.Management.Commands.GetADGroupMember >
Script
Microsoft PowerShell
Active Directory Module
Get-ADGroup
Syntax
powershell -command "(Get-ADGroup -Identity <group-name> -Properties Member).Member.Count"
Sample
powershell -command "(Get-ADGroup -Identity 'Domain Users' -Properties Member).Member.Count"
Output-Image
Output-Text
11
Summary
Using Get-ADGroupMember against “Domain Users“, the original error message read:-
The size limit for this request was exceeded
I was easily misled to think the issue was caused by the number of records returned by the API.
Yet, when we used a different command “Get-ADGroup“, it only returned 11 records.
What gives?