I have a script that has been running fine for a while, but some issues have come up with recent changes in our organization.
The main LDAP query I was using is:
$searcher.Filter = '(&(objectCategory=person)(objectClass=user)(mail=*)(!samaccountname=ITS-*)(!userAccountControl:1.2.840.113556.1.4.803:=2))
I have modified that to now be:
$searcher.Filter = '(&(objectCategory=person)(objectClass=user)(mail=*)(!samaccountname=ITS-*)(!userAccountControl:1.2.840.113556.1.4.803:=2)(|(accountExpires=9223372036854775807)(accountExpires=0)))'
Which I got the (|(accountExpires=9223372036854775807)(accountExpires=0)) from the following article:
Now my main question is, if I use that filter then I am assuming that if a user in AD has the Account Expires selected and the date is in the future, then will they still be filtered out, or only if the account is actually now expired?
If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.