PowerShell Genie

Unlock-ADAccount

Use Unlock-ADAccount to clear the lockout on an Active Directory account after too many failed sign-in attempts. Review examples and related commands.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Unlock-ADAccount

Syntax

1PS> Unlock-ADAccount [-Identity] <ADAccount> [-Server <String>] [-Credential <PSCredential>] [-PassThru] [-WhatIf] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Unlock-ADAccount [-Identity] <ADAccount> [-Server <String>] [-Credential <PSCredential>] [-PassThru] [-WhatIf] [<CommonParameters>]
  1. Stage 1Unlock-ADAccount-Identity -Server -Credential -PassThru -WhatIf

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    Unlock-ADAccount -Identity jsmith

    1PS> Unlock-ADAccount -Identity jsmith -PassThru
    Show reference output

    Sample output · fictional data, shaped like the real thing

    DistinguishedName : CN=Sample User,OU=Users,DC=example,DC=test
    Enabled           : True
    Name              : Sample User
    SamAccountName    : sample.user

    Select Name, SamAccountName

    1PS> Search-ADAccount -LockedOut | Select-Object Name, SamAccountName
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name        SamAccountName
    ----------  --------------
    Jane Smith  jsmith

    Get-WinEvent -LogName Security

    1PS> Get-WinEvent -LogName Security -FilterXPath "*[System[EventID=4740]]" -MaxEvents 5
    Show reference output

    Sample output · fictional data, shaped like the real thing

    TimeCreated           Id    Message
    -----------           --    -------
    9/10/2026 10:51 PM   4740  A user account was locked out.

    Parameters

    Parameter definitions:

    • -Identity
    • -Server
    • -Credential
    • -PassThru
    • -WhatIf

    Unlock-ADAccount on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Unlock-ADAccount when you need to clear the lockout on an Active Directory account after too many failed sign-in attempts. Review examples and related commands. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: An account that immediately locks again may still have a device using an old password. Find the lockout source and update the stored credential rather than repeatedly unlocking the account. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Search-ADAccount. Unlock-ADAccount clears an account lockout; Search-ADAccount finds accounts matching supported conditions. Discovery does not change the state of the accounts returned. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Unlock-ADAccount reference on Microsoft Learn

    Recap

    Unlock-ADAccount Use Unlock-ADAccount to clear the lockout on an Active Directory account after too many failed sign-in attempts. Review examples and related commands.

    Next: Disable-ADAccount
    Genie guideUnlock-ADAccount

    Use Unlock-ADAccount to clear the lockout on an Active Directory account after too many failed sign-in attempts. Review examples and related commands. The console below is pre-loaded — run it, then change a value and run it again.