Unlocks one account that lockout policy has locked after failed logons, reporting when there was nothing to unlock rather than pretending to have done something. The single most delegated task in the library — pair it with the failed logon audit to find out why the account keeps locking.
powershell
# Unlock an AD User Account
# Single use case: unlock one user locked out by failed logon attempts
#-----------------------------------------------------------------
function Write-Log {
param($Message)
Write-Host "<WRITE-LOG = `"*$Message*`">"
}
# --- Parameters (replace via ServerEngine API parameters if needed) ---
$SamAccountName = "j.doe"
if (-not (Get-Module -ListAvailable -Name ActiveDirectory)) {
Write-Log "ActiveDirectory module not available on this host!"
return
}
Import-Module ActiveDirectory
$user = Get-ADUser -Filter "SamAccountName -eq '$SamAccountName'" -Properties LockedOut, LockoutTime -ErrorAction SilentlyContinue
if ($null -eq $user) {
Write-Log "User not found: $SamAccountName"
return
}
if (-not $user.LockedOut) {
Write-Log "User $SamAccountName is not locked out - nothing to do."
return
}
Unlock-ADAccount -Identity $user.DistinguishedName
$user = Get-ADUser -Identity $user.DistinguishedName -Properties LockedOut
if (-not $user.LockedOut) {
Write-Log "User $SamAccountName unlocked successfully."
} else {
Write-Log "WARNING: User $SamAccountName is still locked out!"
}Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in Active Directory
Active Directory User Onboarding with PowerShell
2026-08-17Active Directory User Offboarding with PowerShell
2026-08-17Disable an Active Directory User with PowerShell
2026-08-17Enable an Active Directory User with PowerShell
2026-08-17Reset an Active Directory Password with PowerShell
2026-08-17Move AD Users to an OU by Department with PowerShell
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.