I came across a batch script from Spiceworks to unlock users and passwords.
Instead of giving the option to enter the username to unlock or reset the password, I'd like to pre-define a list of users or usernames to unlock and reset the password.
Take for instance the following.
Please choose a user to unlock or reset password:
(1) - John Doe
(2) - Bob smith
(3) - Kelly Brown
(4) - Vicky White
Here is the batch script from Spiceworks with some minor customization.
@echo Welcome to the tool to unlock users and reset passwords
@echo off
echo.
echo.
cd c:\
@echo NOTE: Username is not-case sensitive.
echo.
SET /P user=Please enter a username to unlock or reset password:
echo.
net user %user% /DOMAIN | FIND /I "account active"
echo.
@echo NOTE: The account will either be Locked "No" or active "Yes"
echo.
echo.
set /p userinp="Would you like to unlock this user?(Y/N)" %
IF "%userinp%"=="N" goto 2
IF "%userinp%"=="Y" goto 1
IF "%userinp%"=="n" goto 2
IF "%userinp%"=="y" goto 1
:end
echo.
@echo If you recieved errors while using this program
echo.
@echo 1. check the spelling of the username.
@echo 2. Ensure that the password meets the policy requirements.
echo.
echo.
echo.
Pause
exit
:done
exit
:3
echo.
@echo NOTE: Password must be 12 characters including 1 uppercase letter, 1 special character, alphanumeric characters.
@echo Password is case sensitive
echo.
SET /P Password=Type a new password:
net user %user% %password% /DOMAIN
goto end
:2
set /p userinp="Would you like to reset the user's password?(Y/N)" %
echo.
If "%userinp%"=="N" Goto done
If "%userinp%"=="Y" Goto 3
If "%userinp%"=="n" Goto done
If "%userinp%"=="y" Goto 3
:1
echo.
Net user %user% /domain /active:YES
goto :2