I am performing some search in the AD. Our company has more than 100.000 computer objects split over 4 domains.
One of the domains has about 65000 - 70000 objects. The others take the rest.
So, I am using Get-ADComputer and Foreach-Object to scan all 4 domains.
At some point, I get an error in the console:
Get-ADComputer : The server has returned the following error: invalid enumeration context.
At MyScript.ps1:36 char:1
- Get-ADComputer -Filter * -SearchBase $Searchbase -Properties Canonicalname …
+ CategoryInfo : NotSpecified: (:) [Get-ADComputer], ADException + FullyQualifiedErrorId : The server has returned the following error: invalid enumeration context.,Microsoft.ActiveDirectory.Management.Commands.GetADComputer</em>
I have searched the internet for this error and there are a lot of people complaining. Still, there was no clean solution.
For some of them, it helped to change the value of ResultPageSize, which is actually a parameter of Get-ADcomputer.
That didn’t work for me. I set it to a low value (like 10) and then to a high value (like 1000). I still get that error.
Some others suggested using the DirectorySearcher for this job, but I would like to use Get-ADcomputer since it’s more convenient.
Did anyone else experience this issue and did anyone get past it?
Thanks in advance!