Create and delete 100 Internet-enabled accounts in five minutes
Top  Previous  Next


The below script can be executed

·by clicking "Run batch" (CTRL+R)  
·by calling SetupBatcher from the command line - from your own program  
·from SetupExplorer [click new] - when you need to add single accounts on a daily basis  

Required

·Windows 2000 or 2003 server  
·Exchange 2000 server  
·IIS 5.0 or 6.0  

(a) Copy the below script (CTRL+C, CTRL+V to paste in SetupBatcher)

[Settings_Begin]
Generator.UserName.DestCol=4
Generator.Username.Series.Prefix=Inet
Generator.Username.Series.Count=10

Generator.Password.DestCol=5
Generator.Password.Random.Len=8
Generator.Password.Random.Chars=0123456789abcdef

BatchSettings.Delimiter=TAB
SET AccountName=%col4%    // %AccountName% instead of %col4% below = easier to change column
SET Password=%col5%
BatchSettings.MarkerCol=7

SET ADDomainPath=dc=com/dc=acme/dc=d29
SET ADOU=Internet
SET ADOUPath=%ADDomainPath%/ou=%ADOU%

SET HomeRoot=c:\users
SET WebServer=d29.acme.com
SET EmailSuffix=acme.com
[Settings_End]

[Machines_Begin]
\\MAIN03
[Machines_End]

[Batch_Begin]
AD.OU.Create %ADDomainPath%,%ADOU%   
Data.Loop   
 AD.Account.Create %ADOUPath%,%AccountName%,%AccountName%,%Password%   
 AD.Account.SetProperty %ADOUPath%/cn=%AccountName%,AccountDisabled,No   
 AD.Account.SetProperty %ADOUPath%/cn=%AccountName%,PWMustChange,No   
 AD.Account.SetProperty %ADOUPath%/cn=%AccountName%,PWNeverExpires,Yes
 Exchange.2k.Mailbox.Create %servername2%, MyOrg, First Administrative Group, First Storage Group, Mailbox Store (main03), %servername2%, %ADDomainPath%, %ADOUPath%/cn=%AccountName%
 Exchange.2k.Mailbox.SetProperty %ADOUPath%/cn=%AccountName%,SMTPEmail,%AccountName%@%EmailSuffix%   
 DOS md %HomeRoot%\%AccountName%   
 DOS md %HomeRoot%\%AccountName%\WWW   
 DOS echo %AccountName% - nothing here yet...>%HomeRoot%\%AccountName%\WWW\default.htm   
 IIS.VirtualDir.Create Web,%servername2%,1,%AccountName%,%HomeRoot%\%AccountName%\WWW   
 IIS.VirtualDir.SetProperty Web,%servername2%,1,%AccountName%,DontLog,True   
 AD.Account.SetProperty %ADOUPath%/cn=%AccountName%,HomePage,http:\\%WebServer%\%AccountName%   
Data.Endloop   
[Batch_End]


[Undo_Batch_Begin]
Data.Loop   
 Exchange.2k.Mailbox.Delete %ADOUPath%/cn=%AccountName%   
 IIS.VirtualDir.Delete Web,%servername2%,1,%AccountName%   
 DOS echo y| rd %HomeRoot%\%AccountName%\ /s   
 AD.Account.Delete %ADOUPath%,%AccountName%   
Data.Endloop   
[Undo_Batch_End]

[Data_Begin]
[Data_End]

(b) Edit the script

Description of the batch section

·Create account  
·Create Exchange 2000 mailbox  
·Change SMTP address from "@d09.acme.com" to "@acme.com"  
·Create home directory  
·Create www directory in home directory  
·Create default web page  
·Create IIS 5.0 web share  
·Set default home page in AD  

Description of the undo section

·Delete Exchange 2000 mailbox  
·Delete IIS 5.0 web share  
·Delete home directory (and all files and directories in it)  
·Delete account  

What to modify

·[Settings]: Domain - example "dc=com/dc=acme/dc=d29" - "SET ADDomainPath=dc=com/dc=acme/dc=D29"  
·[Settings]: Organizational unit - example "MyOU" - "SET ADOUName=MyOU"  
·[Settings]: Home directory root (choose a NTFS volume) - example "c:\users" - "SET HomeRoot=c:\users"  
·[Settings]: Domain name of web server - example "d29.acme.com" - "SET WebServer=d29.acme.com"  
·[Settings]: E-mail suffix - example "@acme.com" - "SET EmailSuffix=acme.com" (Remove Mailbox.SetProperty ...SMTPEmail command in [Batch] if same as server suffix) [Machines] : Change server name  
·[Batch]: Exchange properties - specified in the Exchange.2k.Mailbox.Create and the Exchange.2k.Mailbox.SetProperty commands.  

See also: Create web pages by using the copy command

(c) Create accounts

·The above script contains settings for the SamAccount user name generator and the password generator.  
·Click Action / Run username generator / Serie to create user names.  
·Click Action / Run password generator / Random to create passwords.  
·It is possible to create usernames and passwords automatically with the commands Data.Passwords.Generate and Data.Usernames.Generate.  
·Also have a look at the example Automatically generate unique email addresses.  
·It is of course also possible to manually type full names, account names and passwords in the [Data] section or import data from an external source (see Importing data to the [Data] section).  
·Click "Run Batch" to start the batch job.  

(d) Test the accounts

·Start MMC / "Active Directory Users and Computers", verify the E-mail and the Web-page  



·Start your E-mail client and try to send and receive mail with one of the E-mail accounts  
·Then try one of the home pages, In MMC / "Active Directory Users and Computers", right-click an account and choose "Open home page"  



The result should look like this:



·Start MMC / "Internet Information Services" to look at other IIS settings (the IIS.VirtualDir.SetProperty...DontLog command)  



(e) Delete accounts

·Click "Undo Batch" to run the [Undo] section