Unlocking a user account on a specified Domain Controller

You can use Active Directory Users and Computers snap-in to unlock an user account. In case you do not know the name of the domain controller where the user account got locked, you need to connect to each domain controller using Active Directory Users and Computers and then unlock the user account. Unlock-ADAccount PowerShell cmdlet can help you unlock user account on all domain controllers.

Steps:

  1. Create a Text file.
  2. Specify all the domain controllers in it.
  3. Run below command to unlock an user account on all domain controllers.
  • For /F “Tokens=*” %L IN (DCList.TXT) DO Unlock-ADAccount NickS -Server %L

Above command unlocks user account named NickS all domain controllers specified in the DCList.TXT file.

About Nirmal Sharma

Nirmal is a MCSEx3, MCITP and was awarded Microsoft MVP award in Directory Services and Windows Networking. He is specialized in Directory Services, Failover cluster, Hyper-V, System Center, Windows Azure, and Exchange Servers and has been involved in Microsoft Technologies since 1994. In his spare time, he offers technical help by writing tips and articles on several web sites. Nirmal can be reached at [email protected].

 

1 thought on “Unlocking a user account on a specified Domain Controller”

  1. Exactly what I need, sadly I have not yet been able to make it work
    Am substituting USERID for real userid, and have creatd the DCList.TXT in the same folder containing domain controllers .
    However get missing parenthesis errors

    PS C:\AD> For /F “Tokens=*” %L IN (DCList.TXT) DO Unlock-ADAccount USERID -Server %L
    At line:1 char:4
    + For /F “Tokens=*” %L IN (DCList.TXT) DO Unlock-ADAccount USERID -Serv …
    + ~
    Missing opening ‘(‘ after keyword ‘for’.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingOpenParenthesisAfterKeyword

Leave a Comment

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top