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
IndwesAdminAsked:
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 Specialist/DeveloperCommented:
Upgrade your Powershell to v5+
1
IndwesAdminAuthor Commented:
Thanks ... wasn't even aware that v5 was available ... I will give it a try.
0
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.
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

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

Open in new window

1

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.
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
I guess your number of items is just at the point that this error is occurring with all these properties included
1
IndwesAdminAuthor Commented:
Thank a bunch Shaun!
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
Glad we could help.
Please remember to endorse my, or any other expert's comments that you found helpful.
0
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.