Advertisement
Yevrag35

Check Password Expiration

Aug 7th, 2020
1,843
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $userName = Read-Host "Enter a username to check"
  2.  
  3. $adUser = Get-ADUser -Identity $userName -Properties msDs-UserPasswordExpiryTimeComputed
  4.  
  5. $fileTime = $adUser.'msDs-UserPasswordExpiryTimeComputed'
  6.  
  7. if ($fileTime -ne 9223372036854775807) {
  8.     $expirationTime = [datetime]::FromFileTime($fileTime)
  9. }
  10. else {
  11.     $expirationTime = "Does Not Expire"
  12. }
  13.  
  14. # Then spit out a complete object back to the console
  15. [pscustomobject]@{
  16.     UserName = $adUser.SamAccountName
  17.     ExpirationTime = $expirationTime
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement