Locked accounts are a tax on the help desk. A user mistypes a password three times, a mapped drive retries with stale credentials, a phone in a drawer syncs mail in the background, and suddenly the ticket queue lights up.
What is an Active Directory (AD) account lockout? When a user exceeds the account lockout threshold set in Group Policy, the domain controller flips the lockoutTime attribute on their object and rejects all further logons until the account lockout duration expires, an admin unlocks the account manually, or the reset account lockout counter window passes. Native AD does not provide a built-in self-service account unlock workflow for end users.
Common causes of AD account unlocks include:
For teams managing this manually, PowerShell and the AD module offer a clean, scriptable workflow. This guide walks through each, shows a reusable bulk script you can schedule, and covers where automation can take this process further.
Before any of the cmdlets below will run, the Active Directory Module for PowerShell has to be installed. It ships as part of RSAT (Remote Server Administration Tools).
Get-WindowsCapability -Name RSAT.ActiveDirectory* -Online | Add-WindowsCapability -OnlineInstall-WindowsFeature RSAT-AD-PowerShellImport-Module ServerManagerAdd-WindowsFeature RSAT-AD-PowerShellImport-Module ActiveDirectoryGet-Module -ListAvailable ActiveDirectoryGet-Command -Module ActiveDirectoryNote: If PowerShell returns a module not found error, verify that RSAT is installed and use Windows PowerShell 5.1, since the AD module has limited compatibility with PowerShell 7.x.
Unlock-ADAccount -Identity jsmith -Server "dc01.corp.local"To get the user details of each locked user account in the domain with attribute information—such as SamAccountName, DistinguishedName, SID, ObjectClass, and LastLogonDate—use the following PowerShell script:
Search-ADAccount -LockedOut -UsersOnly |Select-Object SamAccountName, Name, DistinguishedName, LastLogonDate |Format-Table -AutoSizeTo search for locked AD accounts within a specific OU, use the following PowerShell script:
Search-ADAccount -LockedOut -SearchBase "OU=Sales,OU=Users,DC=corp,DC=local"To export locked-out user accounts to a CSV file for auditing, use the following PowerShell script:
Search-ADAccount -LockedOut -UsersOnly | Select-Object SamAccountName, Name, DistinguishedName, LastLogonDate | Export-Csv -Path C:\Reports\LockedAccounts.csv -NoTypeInformationGet-ADUser -Filter {LockedOut -eq $true} looks like it should work, but it won't reliably since the LockedOut parameter is derived at query time and not stored as an AD attribute. Search-ADAccount -LockedOut is the right call here; it reads the lockoutTime parameter directly and applies the domain's lockout duration math on the server side. As a rule, use Search-ADAccount for state queries and Get-ADUser for attribute-level inspection.
Get-ADUser -Identity jdoe -Properties LockedOut, AccountLockoutTime, BadLogonCount, LastBadPasswordAttemptHere's a quick look at the different identity formats that can be input:
Get-ADUser -Identity jdoe # SamAccountName Get-ADUser -Identity "jdoe@corp.local" # UPN Get-ADUser -Identity "CN=John Doe,OU=Sales,DC=corp,DC=local" # DN Get-ADUser -Identity "S-1-5-21-1111111111-2222222222-3333333333-1234" # SID| Property | Meaning |
|---|---|
| LockedOut | Boolean. True means the account is currently locked. |
| AccountLockoutTime | DateTime of the lockout event. Null if not locked. |
| BadLogonCount | Bad attempts counted against this DC since the last reset. |
| LastBadPasswordAttempt | DateTime of the most recent bad attempt. |
The most direct method to unlock an AD account with PowerShell is to use Unlock-ADAccount to clear the lockoutTime attribute on the user object, as shown in this PowerShell script:
Unlock-ADAccount -Identity jdoeTo incorporate a confirmation call as a safety net, force a yes/no prompt:
Unlock-ADAccount -Identity jdoe -ConfirmHere is a sample PowerShell script to identify locked AD user accounts, unlock them, and verify that the account is accessible to the use:
$user = "jdoe"
# Inspect
Get-ADUser $user -Properties LockedOut, AccountLockoutTime | Select-Object SamAccountName, LockedOut, AccountLockoutTime
# Unlock
Unlock-ADAccount -Identity $user -Server (Get-ADDomainController -Discover).HostName
# Confirm release
Get-ADUser $user -Properties LockedOut | Select-Object SamAccountName, LockedOut If LockedOut flips back to True within a few minutes, a common cause is cached credentials.
To unlock all locked user accounts in bulk, use the following PowerShell script:
Search-ADAccount -LockedOut -UsersOnly | Unlock-ADAccountFor a thorough bulk unlock of AD user accounts in PowerShell, complete with logging and error handling, use the following script:
<# Bulk-UnlockADAccounts.ps1 #>
param(
[string]$SearchBase = "OU=Users,DC=corp,DC=local", [string]$LogPath = "C:\Logs\BulkUnlock.log", [string]$Server = (Get-ADDomainController -Discover -Service PrimaryDC).HostName )
Import-Module ActiveDirectory
function Write-Log {
param([string]$Message) "$((Get-Date).ToString('s')) $Message" | Out-File -FilePath $LogPath -Append }
$locked = Search-ADAccount -LockedOut -UsersOnly -SearchBase $SearchBase -Server $Server
if (-not $locked) {
Write-Log "No locked accounts found under $SearchBase."
return
}
foreach ($u in $locked) {
try {
Unlock-ADAccount -Identity $u.DistinguishedName -Server $Server -ErrorAction Stop
Write-Log "Unlocked $($u.SamAccountName)"
}
catch {
Write-Log "FAILED $($u.SamAccountName) :: $($_.Exception.Message)"
}
} A well-tuned policy stops most lockouts before they start. The following table is Microsoft's current security baseline.
| Setting | Recommended value | Reason |
|---|---|---|
| Account lockout threshold | 10 invalid attempts | A threshold of 10 invalid log in attempts is low enough to slow brute-force, high enough to absorb typos. |
| Account lockout duration | 15 minutes | An account lockout duration of 15 minutes lets legitimate users address the issue, and slows down attackers. |
| Reset account lockout counter after | 15 minutes | A reset account lockout limit of 15 minutes matches the lockout duration, thus prevents any accumulation of invalid attempt counts. |
Setting the account lockout threshold to 0 disables lockout entirely and is not recommended for any environment, especially those required to maintain compliance with regulatory frameworks like NIST and PCI DSS.
ADSelfService Plus cuts the help desk out entirely. Users verify their identity using advanced authentication methods—such as FIDO2 passkeys, biometrics, or time-based one-time passcodes—and unlock their own account. The help desk overhead is removed, and the end user saves time spent waiting for a resolution.
ADSelfService Plus also supports scheduled automatic account unlocks, allowing administrators to define a specific time window at which accumulated lockouts are cleared in bulk. This is useful for environments where overnight lockouts from expired cached credentials or failed sync attempts would otherwise generate a wave of morning help desk calls.
To configure:
Active Directory (AD) accounts lock when incorrect password attempts cross the lockout threshold defined in Group Policy. The usual suspects are typos at the logon screen, cached credentials on remote machines, mapped drives still trying an old password, mobile devices polling Exchange using an old password, and service accounts whose password rotated without a service restart.
It's found in by going to Account Policies > Account Lockout Policy > Group Policy. It has three settings: Account lockout threshold (failed attempts before lockout), Account lockout duration (how long the account stays locked), and Reset account lockout counter after (the window in which bad attempts accumulate).
Update saved credentials in Credential Manager, refresh mapped drives, sign mobile mail clients out and back in after every password change, and rotate service account passwords through a managed identity. Tune the lockout threshold so legitimate typos don't trigger it.