Created
April 5, 2012 14:18
-
-
Save clly/2311365 to your computer and use it in GitHub Desktop.
Powershell: Account and Password Info
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
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