Unlock-ADAccount kevmar
So quick to type and it works so well. But unlocking the account is only part of the issue. The real question is why is it locked. If your lucky, the user will say they just miss-typed it a few times and you can let it go. Sometimes you find an account that just locks over and over. Here is a simple command that works really well in my environment to find the source of the issue:
function Get-ADAccountLockInfo
{
[cmdletbinding()]
param(
$ComputerName
= "servername",
[pscredential] $Credential
)
$WinEvent
= @{
ComputerName =
$ComputerName
FilterHashtable = @{logname='security';id=4740}
}
if($Credential)
{
$WinEvent.Credential =
$Credential
}
Get-WinEvent
@WinEvent |
%{
[pscustomobject]@{
TimeCreated = $_.timecreated;
Username = $_.properties[0].value;
ComputerName = $_.properties[1].value
}
}
}
I added a credentials option because I often execute this cross domain. The $WinEvent is a hashtable that I splat to the Get-WinEvent. That makes it easy for me to add the credential to the hashtable when if it is defined.
Any idea how to troubleshoot this with out knowing the event ID to look for? You start with the cell phone and clear any WiFi settings and emails settings. Then do the same for any tablets they have (even at home). Then exit lync and outlook on their laptop and desktop. Open 'Credential Manager' and delete all the saved credentials (do a start menu search for it). Then check all desktops and servers where they may have used RDP to connect to a session but just disconnected when they are done. Then check for services, jobs, tasks, and reporting services connections that may be using that credential.
Yeh, searching the security log is much easier.