Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unlocking Locked Out accounts using PowerShell (not with Quest AD cmdlets)

I'm writing a GUI tool using PowerShell that is able to do most AD related tasks with just a user name and button click. I've done all the usual ones (Create / Remove Users, Create / Remove Security & Distribution Groups, Resetting Passwords, etc) but can't find away of unlocking a "Locked Out" account.

I'm trying to do this without using Quest AD cmdlets as I want a more stand alone solution. So I'm wondering whether is possible with plain PowerShell (1.0 or 2.0) in a Windows 2003 Domain.

Many thanks.

like image 1000
Jonny Avatar asked Apr 06 '10 13:04

Jonny


People also ask

How do you unlock a locked user account in Active Directory?

Open Active Directory Users and Computers. Right-click on the User whose account you need unlocked and select Properties from the context menu. In the Properties window, click on the Account tab. Select the Unlock Account checkbox.

Is account Locked Out PowerShell?

To search for locked out accounts, you can run the Search-AdAccount command using the LockedOut parameter. This will return all users currently locked out granted you have the right to see that.


1 Answers

Set the lockoutTime property of the DirectoryEntry to 0.

Sample:

$x = [ADSI]'LDAP://SomeDN'
$x.lockoutTime = 0
$x.CommitChanges()
$x.Close()
like image 58
dugas Avatar answered Nov 13 '22 06:11

dugas