Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to unlock domain accounts 1

Status
Not open for further replies.

dbustamante

IS-IT--Management
Jul 12, 2010
63
US
Hey Everyone,

I modified one of my old scripts that's pretty basic in what it does checks to see if a user account is locked out if it is it will unlock domain account or tell you it's active and changes passwords for users. But when i get to the change password section if i type in a password that does not meet the password requirements it ask's you again till you finally get it right now even when you put it in with all the requirements it ask's you to type the password never going to the step 4. Can someone tell me what I have to enter to make jump to the last step if it is successful and back to step 3 if it errors out.

Code:
@echo off
:top
cd c:SET /P user=Please Insert A Username:

net user %user% /DOMAIN | FIND /I "account active"
:1
Net user %user% /domain /active:YES
goto :2

set /p userinp="Would you like to unlock the user?(Y/N)" %
IF "%userinp%"=="N" goto 2
IF "%userinp%"=="Y" goto 1 
IF "%userinp%"=="n" goto 2
IF "%userinp%"=="y" goto 1 

:2
set /p userinp="Would you like to change the user's password?(Y/N)" %
If "%userinp%"=="N" Goto exit
If "%userinp%"=="Y" Goto 3
If "%userinp%"=="n" Goto exit
If "%userinp%"=="y" Goto 3


:end

:3
SET /P Password=Type the new password:
net user %user% %password% /DOMAIN 
GOTO end

:4
set /p userinp="Would you like to make any other profiles?(Y/N)" %
If "%userinp%"=="N" Goto exit
If "%userinp%"=="Y" Goto Top
If "%userinp%"=="n" Goto exit
If "%userinp%"=="y" Goto Top

Any help is greatly appreciated.
 
I'd try this:
net user %user% %password% /DOMAIN
IF ERRORLEVEL 1 GOTO end

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
AWESOME! I've been trying all day to figure that out! Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top