Tuesday, October 7, 2008

Creating multiple users

Multiple users at once
To add multiple users at once to the operating system simply use the Filewritefields() script function to write multiple Net User command lines into a Batch file. Once you have written the batch file you can execute it by running the WWDOSCommand() script function.


FOR increment =0 TO 10

Uname = "TestUser"+StringFromIntg(increment,10);LogMessage(Uname);FileWriteMessage( "c:\NewUser.Bat", -1, " Net User "+ Uname + " password /add", 1 );

NEXT;

ReturnValue = WWDosCommand( "c:\Newuser.bat", "maximized" );

The above script will create a Batch file called NewUser.bat. This file will look like:

Net User TestUser0 password /add
Net User TestUser1 password /add
Net User TestUser2 password /add
Net User TestUser3 password /add
(....)
Net User TestUser1o password /add

This file, once executed using the WWDOCCommand() function, will create 10 new users (TestUser0 thru TestUser10 all with a password of Password) on the local machine.

Creating multiple user in AD

You can use csvde -i filename.csv before that prepare the list of user LDAP attributes in the csv file like sAMaccountname, firstnam, lastname, password firstname - fn lastname -ln password - -pwd -i - this switch imports objects to active directory database if you want to know the LDAP attributes first export some objects from AD using csvde -f filename.csv and then you will get a clear picture of what to do now you can add your new user ids in the specified format and using the import switch you can import the object to AD

Multiple commands in batch file loop
In a batch file is possible to execute more than one command for each iteration of a FOR loop (i.e. more than one command for each file of the set):

Create a secondary batch file that processes each file and call it like this: for %f in (*.txt) do call process.bat %f=process.bat=@Echo OffCommand1.exe %1Command2.exe %1etc...

Best to include the PowerShell equivalent: ;-)gci *.txt % {Command1.exe $_.FullName; Command2.exe $_.FullName}

Tuesday, September 9, 2008

About me

Hello!

I'm from Brazil.