Unlock an Active Directory account.

      Unlock-ADAccount [-Identity] ADAccount
         [-AuthType {Negotiate | Basic}] [-Credential PSCredential]
            [-Partition string] [-PassThru] [-Server string]
               [-Confirm] [-WhatIf] [CommonParameters]

   -AuthType {Negotiate | Basic}
       The authentication method to use: Negotiate (or 0), Basic (or 1)
       A Secure Sockets Layer (SSL) connection is required for Basic authentication.

   -Credential PSCredential
       The user account credentials to use to perform this task.
       The default credentials are those of the currently logged on user unless the
       cmdlet is run from an Active Directory PowerShell provider drive.
       If the cmdlet is run from such a provider drive, the account associated with the drive is the default.

       Type a user name, such as "User64" or "Domain64\User64" or specify a
       PSCredential object such as one generated by Get-Credential 

       If a user name is specified, the cmdlet will prompt for a password.

    -Identity ADAccount
       An Active Directory account object by providing one of the following values.
       (The identifier in parentheses is the LDAP display name for the attribute.)

          Distinguished Name 
            Example: CN=JonSmith,CN=Sales,OU=europe,CN=users,DC=corp,DC=SS64,DC=com 
          GUID (objectGUID) 
            Example: 599c3d2e-f72d-4d20-8a88-030d99495f20
          Security Identifier (objectSid) 
            Example: S-1-5-21-3165297888-301567370-576410423-1103
          Security Accounts Manager (SAM) Account Name (sAMAccountName)
            Example: JonSmith

       The cmdlet searches the default naming context or partition to find the object.
       If two or more objects are found, the cmdlet returns a non-terminating error.

       This parameter can also get this object through the pipeline or you can set this
       parameter to an object instance.

       This example shows how to set the parameter to a distinguished name.
          -Identity  "CN=JonSmith,CN=Sales,OU=europe,CN=users,DC=corp,DC=SS64,DC=com"

       This example shows how to set this parameter to a group object instance named "accountInstance".
          -Identity $accountInstance
   -Partition string
       The distinguished name of an AD partition.
       The distinguished name must be one of the naming contexts on the current
       directory server. The cmdlet searches this partition to find the object defined by
       the -Identity parameter. 
       The following two examples show how to specify a value for this parameter.
          -Partition "CN=Configuration,DC=EUROPE,DC=TEST,DC=SS64,DC=COM"
          -Partition "CN=Schema,CN=Configuration,DC=EUROPE,DC=TEST,DC=SS64,DC=COM"
       In many cases, a default value will be used for the Partition parameter if no value
       is specified.  
   -PassThru switch
       Return the new or modified object.
       By default (i.e. if -PassThru is not specified), this cmdlet does not generate any output.
   -Server string
       The AD Domain Services instance to connect to, this may be a Fully qualified domain name,
       NetBIOS name, Fully qualified directory server name (with or without port number)

       Prompt for confirmation before executing the command.

       Describe what would happen if you executed the command without actually executing the command.

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Enable-ADAccount enables an Active Directory user, computer, or service account.

The -Identity parameter specifies the AD user, computer service account, or other service account to be enabled. Identify an account by its distinguished name (DN), GUID, security identifier (SID), or Security Accounts Manager (SAM) account name. Alternatively set the -Identity parameter to an object variable, or pass an account object through the PowerShell pipeline. For example, you can pipe from Get-ADUser to Enable-Account. Similarly, you can use Get-ADComputer and Search-ADAccount to retrieve account objects.

For AD LDS environments, the -Partition parameter must be specified except in the following two conditions:
- The cmdlet is run from an Active Directory provider drive.
- A default naming context or partition is defined for the AD LDS environment. To specify a default naming context for an AD LDS environment, set the msDS-defaultNamingContext property of the Active Directory directory service agent (DSA) object (nTDSDSA) for the AD LDS instance.


Unlock an account with SamAccountName: SteveJ:

PS C:\> Unlock-ADAccount -Identity SteveJ

Unlock an account using a DistinguishedName:

PS C:\> Unlock-ADAccount -Identity "CN=SteveJ,OU=RemoteAccounts,DC=SS64,DC=COM"

Unlock an account on a specific Domain Controller (the DC needs to have the “Active Directory Web Service” started):

PS C:\> import-module activedirectory
PS C:\> Unlock-ADAccount SteveJ -Server ServerDC04

“Kind words will unlock an iron door” ~ Turkish Proverb


Enable-ADAccount - Enable an Active Directory account.
Disable-ADAccount - Disable an Active Directory account.
Search-ADAccount - Get Active Directory user, computer, and service accounts.
WMIC useraccount where... set Lockout="FALSE"

Copyright © SS64.com 1999-2017
Some rights reserved