Author Posts

July 25, 2018 at 10:58 am

Not really a scripting question,

the script below works fine on smaller groups, however my gateway groups can include upwards od 20-30k objects


$Gateways = Get-ADGroup -ldapFilter "(name=*gateway*)" -SearchBase "OU=Internet Mail,DC=global,DC=Contoso,DC=com" -SearchScope OneLevel | select -ExpandProperty name

foreach ($Gateway in $Gateways)

{
    $members = Get-ADGroupMember -Identity $gateway -Recursive | Select -ExpandProperty Name
}

after running for a while it will return a timeout error (per group)


Get-ADGroupMember : The size limit for this request was exceeded
At H:\EAA\Powers Shell Commands\Mail Enabled DL.ps1:6 char:16
+ ...    $members = Get-ADGroupMember -Identity $gateway -Recursive | Selec ...
+                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Europe Gateway:ADGroup) [Get-ADGroupMember], ADException
    + FullyQualifiedErrorId : ActiveDirectoryServer:8227,Microsoft.ActiveDirectory.Management.Commands.GetADGroupMember

how can i increase timeout or make this more efficient, i realise i am not doing anything with $members yet 🙂