Run the code using "Run as administrator".
Password expiration attributes
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
2 answers
Sort by: Most helpful
-
-
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.