Link to home
Start Free TrialLog in
Avatar of IndwesAdmin
IndwesAdmin

asked on

Restore get-aduser functionality

I have a script that has the following command:

$Users = Get-ADuser -Filter * -Properties * | `
      where { $_.whenCreated -ge $week }  | sort | select Name,WhenCreated,Description,EmailAddress

I have been successfully running this as a scheduled task on a Windows 7 box for quite awhile.  Then something changed and the script errors out without returning the list of users.  I have a similar, almost identical, script using get-adgroup which continues to work fine.

Has something changed or broken with the get-aduser command?

Thanks
SOLUTION
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IndwesAdmin
IndwesAdmin

ASKER

Thanks ... wasn't even aware that v5 was available ... I will give it a try.
With v5 I get the same error shown below:
-----
Get-ADuser : The server has returned the following error: invalid enumeration context.
At D:\Program Files\SystemAdmin\PowerShell\_ERW_Reports\ERW-UsersLastWeek2.ps1:29 char:10
+ $Users = Get-ADuser -Filter * -Properties * | `
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-ADUser], ADException
    + FullyQualifiedErrorId : The server has returned the following error: invalid enumeration context.,Microsoft.ActiveDirectory.Management.Commands.GetADUser
 
0 new users in last 7 days
-----

The script is using the same loop used for the get-adgroup script.  Both scripts worked originally.  Now the get-adgroup script works but the get-aduser scripts errors out as shown above.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That did it ... not sure why it worked for so long the way it was and then quit but am very glad to have the report back.  And I got updated to v5 in the process.  Win-Win.
I guess your number of items is just at the point that this error is occurring with all these properties included
Thank a bunch Shaun!
Glad we could help.
Please remember to endorse my, or any other expert's comments that you found helpful.