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?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun VermaakTechnical SpecialistCommented:
Upgrade your Powershell to v5+
IndwesAdminAuthor Commented:
Thanks ... wasn't even aware that v5 was available ... I will give it a try.
IndwesAdminAuthor Commented:
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.
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

Shaun VermaakTechnical SpecialistCommented:
Please try
$Users = Get-ADuser -Filter * -Properties whenCreated,Description,EmailAddress | where { $_.whenCreated -ge $week }  | sort | select Name, WhenCreated, Description, EmailAddress

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IndwesAdminAuthor Commented:
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.
Shaun VermaakTechnical SpecialistCommented:
I guess your number of items is just at the point that this error is occurring with all these properties included
IndwesAdminAuthor Commented:
Thank a bunch Shaun!
Shaun VermaakTechnical SpecialistCommented:
Glad we could help.
Please remember to endorse my, or any other expert's comments that you found helpful.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.