Solved

Powershell - Get-ADGroupMember : The size limit for this request was exceeded

Posted on 2013-10-27
7
9,543 Views
Last Modified: 2013-10-29
Hi EE

I have the script below that I need to get data from a group with over 20k acccounts ..
Any idea what I need to modify to make it work ?

Import-Module Activedirectory
[array]$Members=$null
GC groups.txt | % {
$Group = Get-ADGroup $_  -ErrorAction SilentlyContinue
If ($Group){
$members += Get-ADGroupMember $Group.Name | Get-aduser -Properties * |
Select @{L='GroupName';e={$Group.Name}},Name,Samaccountname,Enabled,LastLogonDate,PasswordLastSet,PasswordExpired,PasswordNeverExpires,CanonicalName
 }
}
$Members | Select * | Export-Csv test1027.csv -NoTypeInformation
0
Comment
Question by:MilesLogan
7 Comments
 
LVL 5

Expert Comment

by:Satish Auti
ID: 39604846
Mark,

will keep in mind.. thanks for reminder :)
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39604969
Based on http://mctexpert.blogspot.in/2013/07/how-to-exceed-maximum-number-of-allowed.html, the ADWS (Active Directory Web Service) cmdlets have server-side limits of
a) the maximum number of objects to retrieve (5000)
b) the allowed time for completing (5 minutes)

The timeout setting is not negotiable, but you can change the object limitation. Though that should only be done in rare cases - most of the time the limit is reasonable, and having to set a bigger one is usually a failure in design.
You'll have to change the file %WinDir%\ADWS\Microsoft.ActiveDirectory.WebServices.exe.config on each ADWS domain controller by searching for <appSettings>, and adding the line
<add key=”MaxGroupOrMemberEntries” value=”25000”/>

Open in new window

(or a higher value).
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39605570
Try this workaround..
Import-Module Activedirectory
[array]$Members=$null
GC groups.txt | % {
$Group = Get-ADGroup $_  -ErrorAction SilentlyContinue
If ($Group){
$members += Get-ADGroup $Group.Name -Properties Members | 
		Select-Object -ExpandProperty Members | 
		Get-ADObject -properties Samaccountname | 
		?{$_.ObjectClass -eq "user"}  | Get-aduser -Properties * |
	Select @{L='GroupName';e={$Group.Name}},Name,Samaccountname,Enabled,LastLogonDate,PasswordLastSet,PasswordExpired,PasswordNeverExpires,CanonicalName
 }
}
$Members | Select * | Export-Csv test1027.csv -NoTypeInformation

Open in new window

0
 
LVL 2

Author Closing Comment

by:MilesLogan
ID: 39607366
Thak you Subsun this worked ..

Thank you all for the other info as well ..
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39608004
It might work, but seems to be ineffective for that much objects, as the AD is queried many, many times instead of having single calls. It depends on the focus - getting it to work at all, or being able to do without much workload and in reasonable time.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

OfficeMate Freezes on login or does not load after login credentials are input.
A brief introduction to what I consider to be the best editor for PowerShell.
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question