Skip to content

Instantly share code, notes, and snippets.

@clly
Created April 5, 2012 14:18
Show Gist options
  • Save clly/2311365 to your computer and use it in GitHub Desktop.
Save clly/2311365 to your computer and use it in GitHub Desktop.
Powershell: Account and Password Info
Function Get-LastPassword($username) {
$a = Get-Module activedirectory
if($a) {
Import-Module activedirectory -force
}
$props = "PasswordExpired", "PasswordLastSet", "LockedOut", "lockoutTime", "LastLogonDate"
$u = get-aduser -Filter {samaccountname -eq $username} -properties $props
write-host "`nPassword Expired: " $u.PasswordExpired
write-host "Account Locked: " $u.LockedOut
if($u.LockedOut) {
write-host "Lockout Time: " $u.lockoutTime
}
write-host "Last Logon: " $u.LastLogonDate
write-host "Password Last Set On: " $u.PasswordLastSet `n
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment