Last active
August 29, 2015 14:08
-
-
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
This file contains hidden or 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
# | |
# 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