@echo off
CLS
:MENU
ECHO.
ECHO ...............................................
ECHO ..Please select an option
ECHO ..for any questions please send an email to < place your support contact info here >
ECHO ...............................................
ECHO..
ECHO 1 - Lock Active Directory Account
ECHO 2 - Unlock Active Directory Account
ECHO 3 - Change Active Directory Password
ECHO 4 - Exit User Management
ECHO..
ECHO..
SET /P M=Type 1, 2, 3 then press ENTER:
IF %M%==1 GOTO LockAcct
IF %M%==2 GOTO UnlockAcct
IF %M%==3 GOTO ChangePwd
IF %M%==4 GOTO eof
:LockAcct
"C:\AD Scripts\lockacct.cmd"
:UnlockAcct
"C:\AD Scripts\unlockacct.cmd"
:ChangePwd
"C:\AD Scripts\changepwd.cmd"
:end
@echo off
REM Prompt for username
:uname
REM If username is blank go to Error prompt. If username is entered prompt for domain name
SET uname=
SET /P uname=Please enter username:
IF "%uname%"=="" (goto uNameError) else (goto domain-name)
REM Prompt for domain name
:domain-name
REM If domain name is blank go to Error prompt. If domain name is entered prompt for password
SET uname=
SET /P domain-name=Please enter domain name:
IF "%domain-name%"=="" (goto domainError) else (goto password)
REM prompt for password
:password
REM this will mask password that is being entered
set "psCommand=powershell -Command "$pword = read-host 'Enter Password' -AsSecureString ; ^
$BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
set passwd=
for /f "usebackq delims=" %%p in (`%psCommand%`) do set passwd=%%p
IF "%passwd%"=="" (goto passwdError) else (goto rasdial)
REM If password is blank go to password Error prompt. If password is entered start dialing VPN connection
REM SET /P passwd=Please enter your password:
REM IF "%passwd%"=="y" (goto passwdError) else (goto changePass)
:changePass
net user %uname% %password% /%domain-name% /Active:Yes /logonpasswordchg:yes
goto end
REM Username is Blank Error MEssage
:uNameError
ECHO You did not enter a username.
SET unameretry=
SET /P unameretry=Retry? (y, then enter or press enter to exit):
IF /i "%unameretry%"=="y" (goto uname) else (goto end)
REM Domain name is Blank Error MEssage
:domainError
ECHO You did not enter a domain name.
SET domainNameretry=
SET /P domainNameRetry=Retry? (y, then enter or press enter to exit):
IF /i "%domainNameRetry%"=="y" (goto domain-name) else (goto end)
REM Password is Blank Error Message
:passwdError
ECHO You did not enter a password.
SET passRetry=
SET /P passRetry=Retry? (y, then enter or press enter to exit):
IF /i "%passRetry%"=="y" (goto password) else (goto end)
:end
"C:\AD Scripts\usermgmt.cmd"
@echo off
REM Prompt for username:uname
:uname
REM If username is blank go to username Error prompt.
SET uname=
SET /P uname=Please enter username:
IF "%uname%"=="" (goto uNameError) else (goto domain-name)
REM Prompt for domain name
:domain-name
REM If domain name is blank go to domain Error prompt.
SET domain-name=
SET /P domain-name=Please enter domain name:
IF "%domain-name%"=="" (goto domainError) else (goto lockAccount)
:lockAccount
Net user %uname% /%domain-name% /active:No
goto end
REM Username is Blank Error MEssage
:uNameError
ECHO You did not enter a username.
SET unameretry=
SET /P unameretry=Retry? (y, then enter or press enter to exit):
IF /i "%unameretry%"=="y" (goto uname) else (goto end)
REM Domain name is Blank Error MEssage
:domainError
ECHO You did not enter a domain name.
SET domainNameretry=
SET /P domainNameRetry=Retry? (y, then enter or press enter to exit):
IF /i "%domainNameRetry%"=="y" (goto domain-name) else (goto end)
:end
"C:\AD Scripts\usermgmt.cmd"
@echo off
REM Prompt for username:uname
:uname
REM If username is blank go to username Error prompt.
SET uname=
SET /P uname=Please enter username:
IF "%uname%"=="" (goto uNameError) else (goto domain-name)
REM Prompt for domain name
:domain-name
REM If domain name is blank go to domain Error prompt.
SET domain-name=
SET /P domain-name=Please enter domain name:
IF "%uname%"=="" (goto domainError) else (goto lockAccount)
:lockAccount
Net user %uname% /%domain-name% /active:yes
goto end
REM Username is Blank Error MEssage
:uNameError
ECHO You did not enter a username.
SET unameretry=
SET /P unameretry=Retry? (y, then enter or press enter to exit):
IF /i "%unameretry%"=="y" (goto uname) else (goto end)
REM Domain name is Blank Error MEssage
:domainError
ECHO You did not enter a domain name.
SET unameretry=
SET /P domainRetry=Retry? (y, then enter or press enter to exit):
IF /i "%domainretry%"=="y" (goto domain-name) else (goto end)
:end
"C:\AD Scripts\usermgmt.cmd"
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)