Thursday, March 20, 2008

Bulk Users Import to Active Directory

Bulk Users creation to windows 2003 domain.
Create one excel file name is user5.xls.

Type fill givenname and sn filed. Also change your ou and domain name.


































Save as the excel file to users5.csv file














Delete unwanted field of emp.code.

Finally save this file user5.csv

goto domain command prompt type

c:\csvde -i -f user5.csv

After that all users are imported to active directory. Next step is enable the account and Passoword using the following script.

' start script
' PwdLastSet.vbs
' Example VBScript to FORCE a user's password change
' Author Ulrich P amended by Guy Thomas
' Version 2.0 - October 17th 2004
' ---------------------------------------------------------'
Option Explicit
Dim objOU, objUser, objRootDSE
Dim strContainer, strLastUser, strDNSDomain, strPassword
Dim intCounter, intAccValue, intPwdValue

Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
intAccValue = 544
intPwdValue = 0

' --------------------------------------------------------'
' Important change OU= to reflect your domain
' --------------------------------------------------------'

strContainer = "OU=Test, "
strPassword = "P@ssw0rd"

' -------------------------------------------------------'
' Makes the user change P@ssw0rd at first logon
' -------------------------------------------------------'

strContainer = strContainer & strDNSDomain

set objOU =GetObject("LDAP://" & strContainer )
intCounter = 0
For each objUser in objOU
If objUser.class="user" then
objUser.SetPassword strPassword
objUser.SetInfo

objUser.Put "pwdLastSet", intPwdValue
objUser.SetInfo

objUser.Put "userAccountControl", intAccValue
objUser.SetInfo
intCounter = intCounter +1
strLastUser = objUser.Get ("name")
End if
next

WScript.Echo strPassword & " is Password. UserAccountValue = " _
& intAccValue
WScript.Quit

' End of Script

copy and paste this script to PwdLastSet.vbs and run this file.

If you want excel file, csv file and script file

Excel file
Csv file
script file

Fell free leave some comments....

No comments: