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
Windows 7

Avatar of undefined
Last Comment
Shaun Vermaak

8/22/2022 - Mon
SOLUTION
Shaun Vermaak

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
IndwesAdmin

ASKER
Thanks ... wasn't even aware that v5 was available ... I will give it a try.
IndwesAdmin

ASKER
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
Shaun Vermaak

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
IndwesAdmin

ASKER
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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Shaun Vermaak

I guess your number of items is just at the point that this error is occurring with all these properties included
IndwesAdmin

ASKER
Thank a bunch Shaun!
Shaun Vermaak

Glad we could help.
Please remember to endorse my, or any other expert's comments that you found helpful.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.