Aaron
Aaron

Reputation: 3325

Active Directory password expiration in powershell

When I retrieve the password expiration, it shows a date 6 months after they changed their password, when it is actually set to 3 months. Is there a way to see this updated date? Or where is it being set at that I can pull that date in?

I currently am using this to output:

Get-ADUser -identity $ntaccount
@{ Name = "Expiration Date"; Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}

Upvotes: 0

Views: 14113

Answers (1)

Matt
Matt

Reputation: 46710

Not sure what you are expecting to find but this code works properly. Your code appears to be missing a couple of things. Namely your first line does not feed into the second and your are not returning the needed property from Get-Aduser which is msDS-UserPasswordExpiryTimeComputed

Get-ADUser -identity accountname -Properties msDS-UserPasswordExpiryTimeComputed | 
    select samaccountname,@{ Name = "Expiration Date"; Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}

My account expires just under 42 days at the time of this post. My date is correct.

samaccountname Expiration Date     
-------------- ---------------     
myaccount      3/6/2015 11:34:29 AM

Are you expecting something else?

Upvotes: 2

Related Questions