自动创建用户脚本

Published on 2014 - 09 - 09

以前在赛诺格兰工作的时候写的脚本,
自动创建用户脚本,选择所属分组


@echo off
@Title Create User
@color 0a
echo enter your user name:
set /p username=
echo Enter Last Name:
set /p lastname=
echo Enter First Name:
set /p firstname=
dsadd user cn=%username%,ou=Beijing,dc=sinogram,dc=cn -pwd www.123.com -canchpwd yes -ln %lastname% -fn %firstname%
:Start
echo Please select the user group:
echo (a)BEI-Administration
echo (b)BEI-Algorithm
echo (c)BEI-Detector
echo (d)BEI-Electronics
echo (e)BEI-Finance
echo (f)BEI-HR
echo (g)BEI-ITTeam
echo (h)BEI-Mechanics
echo (i)BEI-SoftwareDev
echo (j)BEI-System
set groupname=
set /p groupname= Please Enter:
If "%groupname%"=="" Goto Start
If Not "%groupname%"=="" Set groupname=%groupname:~0,1%
If /I "%groupname%"=="a" Goto :a
If /I "%groupname%"=="b" Goto :b
If /I "%groupname%"=="c" Goto :c
If /I "%groupname%"=="d" Goto :d
If /I "%groupname%"=="e" Goto :e
If /I "%groupname%"=="f" Goto :f
If /I "%groupname%"=="g" Goto :g
If /I "%groupname%"=="h" Goto :h
If /I "%groupname%"=="i" Goto :i
Goto Start
:a
net group BEI-Administration %username% /add
goto :end
:b
net group BEI-Algorithm %username% /add
goto :end
:c
net group BEI-Detector %username% /add
goto :end
:d
net group BEI-Electronics %username% /add
goto :end
:e
net group BEI-Finance %username% /add
goto :end
:f
net group BEI-HR %username% /add
goto :end
:g
net group BEI-ITTeam %username% /add
goto :end
:h
net group BEI-Mechanics %username% /add
goto :end
:i
net group BEI-SoftwareDev %username% /add
goto :end
:j
net group BEI-System %username% /add
pause