Home > Enterprise >  Unlock local user accounts via Powershell
Unlock local user accounts via Powershell

Time:10-22

I will like to know if there is a way i can use to unlock the local account via powershell. I know there is Unlock-ADAccount to unlock the AD accounts. Is there something similar we can use for unlocking local accounts? I checked Set-Localuser but it does not have Accountlocked that you can set it to false like -PasswordNeverExpires $True.

I have a script that creates local accounts used in our organization and sets the required properties. the script also enables any disabled local accounts that are supposed to be enabled and removes all other local accounts that are not supposed to be on the system. I managed to achieve all that but I also need to have the script to be able to unlock the needed local accounts in case they get locked out without having to unlock them via manually via lusrmgr.msc . Any help will be really appreciated. Thank you in advance.

CodePudding user response:

No. There are two ways to get a local account to unlock:

  1. Set the Account Unlock Threshold.
  2. An Administrator must manually do it through lsusrmgr.msc.

Maybe there is something in the registry or buried in the Win32/.NET APIs somewhere but I am not aware of any method to do it on-demand via automation.

  • Related