0

I currently need to export the groups of all users in my domain and I get the error Error with Get-ADUser: Invalid enumeration context. In the script I indicate an ou that has 1300 users and it only brings me approximately 900. how could i solve it? I attach the script.

I attach the script

franco
  • 1
  • 2

1 Answers1

0

You are hitting the 2 minute time limit. I do not believe there is a way to adjust the timeout, but you can filter:

Get-ADObject -Filter 'CN -like "*a*"'

Repeat a - z

That will give you everyone. You could probably come up with a more creative filter, but this is the answer.

https://learn.microsoft.com/en-us/previous-versions/windows/server/hh531527(v=ws.10)?redirectedfrom=MSDN

From Microsoft:

Timeout Behavior
The following statements specify timeout conditions within the Active
Directory module and describe what can be done about a timeout them.

The default Active Directory module timeout for all operations is 2
minutes.

For search operation, the Active Directory module uses paging control
with a 2-minute timeout for each page search.

Note: Because a search may involve multiple server page requests the
overall search time may exceed 2 minutes.

A TimeoutException error indicates that a timeout has occurred.

For a search operation, you can choose to use a smaller page size, set
with the ResultPageSize parameter, if you are getting a TimeoutException
error.

If after trying these changes you are still getting a TimeoutException
error, consider optimizing your filter using the guidance in the
Optimizing Filters section of this topic.
Technoob1984
  • 172
  • 9