Password expiration attributes

John52180627 1 Reputation point
2023-01-05T20:47:03.783+00:00

We have a script running Get-ADUser to determine expiration dates of passwords. It recently stopped working. Domain Admins running Get-ADUser and the relevant -Properties are able to obtain PasswordExpired, PasswordLastSet, and PasswordNeverExpires values but a non-admin is only able to see PasswordLastSet as existing and that is blank (the others don't acknowledge their existence).

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2023-01-05T22:13:15.19+00:00

    Run the code using "Run as administrator".


  2. Limitless Technology 44,766 Reputation points
    2023-01-06T14:02:50.773+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query.

    You can try this command to get the password expiration:

    Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} –Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed" |
    Select-Object -Property "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.