I am using Powershell to determine the password expiry date for domain accounts. I have used the following command to get this information:
Get-ADUser -Filter {SamAccountName -eq "<username>"} -Properties "DisplayName" , "msDS-UserPasswordExpiryTimeComputed"
I then covert this value to a meaningful date by using:
[datetime]::FromFileTime(<computed filetime from above command>)
This works fine for all the domains I use, except one. In that domain I get a value of 9223372036854775807
as the msDS-UserPasswordExpiryTimeComputed
. I am not able to use the FromFileTime
function to convert this number into a date. It throws as error. Upon researching I have found that this number means that the password is set not to expire. However, I know that passwords do expire in this domain. Further, the PasswordNeverExpires
property from the Get-ADUser
cmdlet shows as False
.
How can I get 9223372036854775807
from msDS-UserPasswordExpiryTimeComputed
attribute and get a False
from the PasswordNeverExpires
property? This seems like a contradiction. What am I missing? Are there other situations when msDS-UserPasswordExpiryTimeComputed
could be 9223372036854775807
too? Thanks.