简体   繁体   中英

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")}}

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM