If you use the -PasswordExpired switch you cannot use the -DateTime parameter. The password has either expired or it hasn't. Perhaps you're reading the -PasswordexpirED as if it were -PasswordExpirING?
Question on Search-ADAccount

Hello!
On more question on quering AD in PS, please:
According to Search-ADAccount the -DateTime parameter can be used for both -AccountExpiring and -PasswordExpired, but the -DateTime + -PasswordExpired would always raise the error, both in AD2008R2 and AD2022 - is it a bug in Search-ADAccount or incorrect documentation?
Thank you in advance,
Michael
Windows for business | Windows Server | User experience | PowerShell
2 additional answers
Sort by: Most helpful
-
Mikhail Firsov 1,881 Reputation points
2022-06-06T12:58:07.373+00:00 "Perhaps you're reading the -PasswordexpirED as if it were -PasswordExpirING?" - the ability to use the -DateTime along with -PasswordexpirED does realy turn "-PasswordexpirED" into "-PasswordExpirING" and I would have never thought about it if I hadn't seen the documentation above.
"The password has either expired or it hasn't. " - agree.
"If you use the -PasswordExpired switch you cannot use the -DateTime parameter." - as you see the article Search-ADAccount says you can.
Am I getting it right that "If you use the -PasswordExpired switch you cannot use the -DateTime parameter. means documentation error?
Regards,
Michael -
Mikhail Firsov 1,881 Reputation points
2022-06-07T10:28:35.757+00:00 The set you mentioned is correct, but I referenced this:
"-DateTime
Specifies a distinct time value for Search-ADAccount parameters such as AccountExpiring, AccountInactive, and PasswordExpired."- and this obviously is not correct :(
Thank you for the help!
Regards,
Michael