Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $userName = Read-Host "Enter a username to check"
- $adUser = Get-ADUser -Identity $userName -Properties msDs-UserPasswordExpiryTimeComputed
- $fileTime = $adUser.'msDs-UserPasswordExpiryTimeComputed'
- if ($fileTime -ne 9223372036854775807) {
- $expirationTime = [datetime]::FromFileTime($fileTime)
- }
- else {
- $expirationTime = "Does Not Expire"
- }
- # Then spit out a complete object back to the console
- [pscustomobject]@{
- UserName = $adUser.SamAccountName
- ExpirationTime = $expirationTime
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement