Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mtboren/5e807b8a7eab8211d7302b6548a9a9a8 to your computer and use it in GitHub Desktop.
Save mtboren/5e807b8a7eab8211d7302b6548a9a9a8 to your computer and use it in GitHub Desktop.
Get AD User info, to include PasswordExpiration datetime
## example of getting, for one user, some choice properties, to include PasswordExpiration datetime (using the ActiveDirectory PowerShell module from Microsoft)
## where there might be some AD property that gives that password expiration info in proper datetime format already, my quick search found no such property; so, we can use the given .NET method to convert from filetime to a proper datetime -- yay!
#Requires ActiveDirectory
Get-ADUser rickyscroter -Properties *, msDS-UserPasswordExpiryTimeComputed | Select-Object -Property displayname, *passw*, @{n="PasswordExpiration"; e={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}
## credit for reporting of said somewhat cryptic AD property 'msDS-UserPasswordExpiryTimeComputed': https://activedirectorypro.com/how-to-get-ad-users-password-expiration-date/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment