2 years ago, when the batch learning to write their own domain Add / Remove Accounts tool, and now also in use in the workplace on their own, there is no technical content, nothing more than some of the batch commands and dsadd user, dsquery user and so some common command.褰撶劧鏈?父鐢ㄧ殑灏辨槸瀵煎叆浜嗭紝鍐欑殑鍔熻兘杩樻槸姣旇緝绠?崟鐨勶紝姣曠珶鎴戞湰浜烘墠鐤忓娴咃紝涔熷笇鏈涢珮鎵嬭兘澧炲姞鏇存湁鏁堢殑鍔熻兘锛岀粰鍠滄鎵瑰鐞嗙殑鏈嬪弸浣跨敤鍚с?
Before use to establish users.txt, the following format:
Bill. Gates bill bill@microsoft.com password01 @
Parameters Note: cn name-samid-upn - pwd
Has joined the user exists, in the accession prompted wrong judgments, orders due cmd weak, forced to quote the delay variable, so that can not be a "!" Character, so please set the password in the users.txt Do not use "!."
By default only support two domain names (eg: microsoft.com), if your domain is (soft.microsoft.com) 3 domain then please modify this batch.
Some code:
銆??@echo off & setlocal ENABLEDELAYEDEXPANSION
銆??:start
cls
title = In the field Add / Remove Account tool, BY sunhtcool
銆??rem mode con cols=60 lines=50
color 0b
echo% date%
echo.
set menu =
銆??echo [1]鍦ㄥ煙涓壒閲忔坊鍔犺处鎴?br />
echo.
echo [2] to delete accounts in the domain
echo.
echo [3] to find at least several weeks inactive (not logged in) users
echo.
echo [4] to find the user account is disabled
echo.
echo [5] Exit
echo.
set / p menu = "Please enter your choice:"
if "% menu%" == "1" goto AddUsers
if "% menu%" == "2" goto DelUsers
if "% menu%" == "3" goto QueryUsersweeks
銆??if "%menu%" == "4" goto QueryUsersDisabled
if "% menu%" == "5" goto: eof
echo selection is invalid, please re-select!
pause> nul
銆??goto start
銆??:AddUsers
cls
set Domain_name =
set / p Domain_name = "Please enter your domain name (eg: microsoft.com):"
銆??for /f "tokens=1,2 delims=." %%a in ("%Domain_name%") do (set Domain_name1=%%a
set Domain_name2 =%% b)
for / f "tokens = 1-4 delims ="%% a in (users.txt) do (dsquery user-o dn | findstr / c: "%% a"
rem variable to monitor error
echo! ERRORLEVEL!>> error.txt
if "! ERRORLEVEL!" == "0" (@ echo username [%% a] failure to add already exists ...
) Else (@ call: OK%% a%% b%% c%% d ...)
)
銆??ping 127.0.0.1 -n 3 >nul
echo.
echo command to complete, press any key to exit ...
pause> nul
start dsa.msc
goto: start
: OK
rem delayed variable attention will abandon all! No.
銆??dsadd user "cn=%1,cn=users,dc=%Domain_name1%,dc=%Domain_name2%" -samid %2 -upn %3 -pwd %4 -pwdneverexpires yes -mustchpwd no >nul 2>nul
if not "! ERRORLEVEL !"==" 0" (echo user Samid [% 2] failed to add already exists ...) else (
echo Adding user [% 1] success ...)
echo.
銆??goto :eof
銆??:DelUsers
cls
銆??echo [1]鍒犻櫎瀹瑰櫒涓崟涓敤鎴?br />
echo.
銆??echo [2]鍒犻櫎缁勭粐鍗曚綅涓?OU)鍗曚釜鐢ㄦ埛
echo.
echo [3] bulk deletion of users (not including the deleted OU organizational unit)
echo.
echo [4] bulk deletion of users (including the deleted OU organizational unit)
echo.
銆??echo [5]杩斿洖涓婁竴涓洰褰?br />
銆??set DelUs=
set / p DelUs = "Please enter your choice:"
if "% DelUs%" == "1" goto Del_Singel
if "% DelUs%" == "2" goto Del_Ou
銆??if "%DelUs%" == "3" goto Del_OuS1
if "% DelUs%" == "4" goto Del_OuS2
if "% DelUs%" == "5" goto start
echo selection is invalid, please re-select!
goto DelUsers
: Del_Singel
cls
set Singel =
set Cn_1 =
銆??set Domain_pname=
set / p Singel = "Please enter the user's DN (distinguished name) (eg: John Smith):"
if "% Singel%" == "" echo user name can not be empty, please re-enter! & pause> nul & goto Del_Singel
for / f "tokens =*"%% t in (''dsquery user-o dn ^ | find / i "% Singel%"'') do set Uesr =%% ~ t
echo% Uesr%
if "% Uesr%" == "" echo This user name does not exist, please re-enter! & pause> nul & goto Del_Singel
pause
set / p Cn_1 = "Please enter your user name where the container (for example: users):"
if "% Cn_1%" == "" echo container name can not be empty, please re-enter! & pause> nul & goto Del_Singel
銆??set /p Domain_pname="璇疯緭鍏ヤ綘鐨勫煙鍚?渚嬪锛歮icrosoft.com):"
銆??if "%Domain_pname%" == "" echo 鍩熷悕涓嶈兘涓虹┖,璇烽噸鏂拌緭鍏? & pause>nul & goto Del_Singel
for / f "tokens = 1,2 delims =."%% a in ("% Domain_pname%") do (set Domain_namep1 =%% a
銆??set Domain_namep2=%%b)
dsrm "cn =% Singel%, cn =% Cn_1%, dc =% Domain_namep1%, dc =% Domain_namep2%"-noprompt> nul
. . . . . . . . .
Add to delete the domain account tools: http://bbs.chinaitlab.com/thread-317569-1-1.html
相关链接:
PREMIER Religion
News about File And Disk Management
Wmv Dvd
Comparison of access methods: optical access with ADSL access, contest
Shop Development
Female Employment: Shuobo difficult job there is the cycle undergraduate
CSS Syntax Guide (4) text fill, borders, boundaries and location of the property (2)
MKV To Xbox 360
DivX to MPEG
Games Arcade Evaluation
What rod dealer outlets
IP And MAC Binding Of Crack
Qwest MCI Crush On The Bride Price Increase To 9 Billion U.S. Dollars
RMVB to MP4
Pan On Why OO + object-oriented multi-layer structure [2]