PowerShell: Unlock Active-Directory Users Account

November 23, 2015

no comments

How to: Unlock Active-Directory Users Account via PowerShell

First, open PowerShell in administrator right.

Import Module Active-Directory 

Import-Module ActiveDirectory

 

Run command Search-ADAccount – LockedOut

Search-ADAccount -LockedOut

If there are any locked accounts, they will be shown like the following example:

2015-11-23 11_29_14-Windows PowerShell

To unlock account(s), add Unlock-ADAccount parameter to basic command

2015-11-23 11_36_30-Windows PowerShell

#Examples

Search and unlock all account in domain

Search-ADAccount -LockedOut | Unlock-ADAccount

Limit the search to a specific OU,

Search-ADAccount -SearchBase "OU=Users,OU=Skepper,DC=MyDomain,DC=net" -LockedOut | Unlock-ADAccount

Limit search to  Users Only

Search-ADAccount -UsersOnly -LockedOut | Unlock-ADAccount

 

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.