Batch file to create computer accounts in Active Directory. The list of computer accounts to be created, is included in the batch file : this batch file reads itself as inputfile.
The following script obviously assumes a certain design in the Active Directory : an Organizational Unit logical structure, users with membership to groups, therefore also a logical structure of somain local and global groups, etc. This is described in Active Directory Design and Implementation.
@GOTO batch computer Desription Location ------------------------------------------------------------- PC01 testPC01 PC02 testPC02 PC03 testPC03 LAP02 laptop_test1 LAP03 laptop_test2 :batch @echo off REM Koen Noens REM March 2005 REM structuur van AD nog bekijken, en dit script aanpassen indien nodig REM voorlopig : - OU = theOffice/computers REM - alle computers in zelfde OU set theDomain=dc=kicks, dc=local dsadd ou "ou=computers, ou=theOffice, %theDomain%" FOR /F "skip=4 tokens=1-3" %%i in (%0)do ( if "%%i" == "" GOTO BATCHEND if "%%i" == ":batch" GOTO BATCHEND dsadd computer "cn=%%i, ou=computers, ou=theOffice, %theDomain%" -SAMID %%i -desc %%j ) :batchend exit /B