Sync account from AD to front end application

Hello Guys ,

I need your suggestions…When I run First Cmdlet it works fine however Second option which I want to use does not work and giving me error “Error getting objects: The server has returned the following error: invalid enumeration context”

I followed article

I tried resultpagesize with different values but it does not work either. I check the second Cmdlet with measure command and it is taking 17 minutes to fetch AD objects and time out time is mentioned in the ADWS server is 30 minutes.

Could you please help me to understand what is wrong I am doing so I can troubleshoot this error as we do not want to user first optionas and we want to import all account irrespective date and time.

First Cmdlet $from = ((Get-Date).AddDays(-100)).date
$to = ((Get-Date).AddDays(0)).date

     $A = @(Get-ADUser -Filter { whenCreated -ge $from -and whenCreated -le $to } -Properties * -Server $DomainController) 

Second Cmdlet

    $A = @(Get-ADUser -Filter '*' -Properties * -Server $DomainController)

Still re-building my test lab at the moment, so can’t test just yet. But I think you just need to remove the single quotes around your wildcard.

$A = @(Get-ADUser -Filter * -properties * -server $DomainController)

Thanks for the reply, I will try now what you suggested and let you know output though I wanted to remove date filter so that we can get the data without mentioning days.


Just tested and it did not work

2017-07-21 10:19, Error getting objects: The server has returned the following error: invalid enumeration context.

Do you really All Properties ?? Try with just the properties you need as -Filter * -Properties * is going to bring down a lot of stuff you probably don’t require

Hi Simon, Thanks for the reply

As of now we are using
$from = ((Get-Date).AddDays(-100)).date
$to = ((Get-Date).AddDays(0)).date

$A = @(Get-ADUser -Filter { whenCreated -ge $from -and whenCreated -le $to } -Properties * -Server $DomainController

Here also we are fetching all properties, I understand your point that It may bring nonindexed properties as well which is no use for me or for application but I wanted to make same as previous. Just looking to get rid of days filter so it could fetch and updated records without seeing the number of days…

But the data set you are bringing back with dates in it will be a lot smaller. Try with just the basic properties and see if that is enough info (on the without dates query)

Yes, data is small when we try to run it manually putting days -500 to 0, -500days to -1000days, -1000days to -1500days and list go on till 4000days. We are not sure as of what all properties would be enough but surely will see that option . I was wondering If we could do this something about filter we need not run manually by entering days, however, seems unreal. Thanks for the reply and suggestion.