I'm trying to use Powershell to give me the user accounts of those accounts that have password set to not expire.
I have written this:
Search-ADAccount -PasswordNeverExpires -usersonly |get-aduser -Filter 'name -like "*wildcard*"' | FT Name, ObjectClass
When run, this first supplies everything that has my *wildcard* in the name, I thought the first part of the script would only send the user accounts that are set to not expire, clearly it does not.
Second, after the list of users is complete it throws an error over and over for 10-15 seconds:
Search-ADAccount : The server has returned the following error: invalid enumeration context.
At line:1 char:1
+ Search-ADAccount -PasswordNeverExpires -usersonly |get-aduser -Filter 'name -lik ...
+ CategoryInfo : NotSpecified: (:) [Search-ADAccount], ADException
+ FullyQualifiedErrorId : The server has returned the following error: invalid enumeration context.,Microsoft.ActiveD