|
Answer» I would like to know how to add a list of user from a file in batch file. and also how to add directory/file in using batch file?
thank youAdd a user to what? Local computer users? Domain computer users? Active Directory? SQL Server? Oracle?add to active directory. ThanksYou need to write an ADSI script.
strContainer = "" strName = "EzAdUser"
'*********************************************** '* Connect to a container * '*********************************************** Set objRootDSE = GetObject("LDAP://rootDSE") If strContainer = "" Then Set objContainer = GetObject("LDAP://" & _ objRootDSE.Get("defaultNamingContext")) Else Set objContainer = GetObject("LDAP://" & strContainer & "," & _ objRootDSE.Get("defaultNamingContext")) End If '*********************************************** '* End connect to a container * '***********************************************
Set objUser = objContainer.Create("user", "cn=" & strName) objUser.Put "sAMAccountName", strName objUser.SetInfo
You have to make changes to the strContainer and strName variables. Save the file with a VBS extension and run it from the Windows Run Box. Include the extension for execution. FEEL free to CONFIGURE the script to your needs.
Hope this helps. sorry, i can't get you. PERHAPS you can explain in a simple way. previously i thot i can write a .bat file and run it in dos prompt, which will be able to generate a set of user based on an INPUT userlist file.I understand that Dsadd utility found in windows 2003 can add a user to Active Directory (AD) from the command line without using a script?
what if i wan to create not one a single user, but a list of user which import from a file, can this command help me without using a script? Oops, I REALLY screwed this one up. You can use DSADD from the command line.
for /f %%i in (namefile.txt) do dsadd ...
%%i is a user name from your file namefile.txt is the label of the file containing the names ... are the DSADD switches (there is boat load of them)
If you type DSADD /? at the prompt, you should get a list of all the switches, or try this site:
http://www.microsoft.com/windowsxp/home/using/productdoc/en/default.asp?url=/windowsxp/home/using/productdoc/en/dsadd_user.asp
Personally, I would use a script. It's much more powerful than batch language and was designed to automate these types of tasks.
Good luck.
|