Skip to content

Instantly share code, notes, and snippets.

@palefailmel
Last active August 29, 2015 14:08
Show Gist options
  • Save palefailmel/a018025b0f12404d3d0e to your computer and use it in GitHub Desktop.
Save palefailmel/a018025b0f12404d3d0e to your computer and use it in GitHub Desktop.
A simple way to search for locked out accounts that were probably locked out by a bad password in active directory
#
# Date : 2014-10-31 M. Stevenson - Initial Version
# Desc : Get users that were probably locked out by a
# bad password
#
Get-ADUser -Filter { LockoutTime -gt 0 -and BadPwdCount -ge 5 } -Properties * | sort lockouttime -descending | ForEach-Object {
$lockouttime = [DateTime]::FromFileTimeUtc($_.lockoutTime)
$bptime = [DateTime]::FromFileTimeUtc($_.badPasswordTime)
Write-Host "================================================================================="
Write-Host "$($_.SAMAccountName) ($($_.Name)) locked out on $lockouttime"
Write-Host "Bad Password Time - $($bptime)"
Write-Host "================================================================================="
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment