Last active
May 17, 2019 14:56
-
-
Save mtboren/5e807b8a7eab8211d7302b6548a9a9a8 to your computer and use it in GitHub Desktop.
Get AD User info, to include PasswordExpiration datetime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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