One possibility would be to check out the DSADD command in help&support.
It has a ton of parameters (not all of them needed in your case), but you
can easily introduce new columns into your excel, holding those command and
parameter references, export your excel into a text-style cmd. file and run
it.
george
Or, alternately, you could check out CSVDE.EXE. This application accepts
input in the form of a csv file (easily generated from an excel
spreadsheet), and creates accounts according to the info provided. Note
that, unless you have a small organization, you are probably going to want
to specify things like the OU that each account should be created in.
/Al
Well, I thought of suggesting that one, but given the OP's stated initial
information, CSVDE won't let you specify a password upon input, whereas
DSADD does.
Besides, all the DSxxx commands are less 'error-prone' because the input is
parameter-based (like -fn <first name> -ln <last name> -pwd <password>),
compared to the 'positional field'-approach of CSVDE.
What's more, CSVDE does not allow you to 'modify' if you happen to have made
a mistake upon input, whereas the DS-commands (DSMOD) will.
:-))
george
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open
("\\Domain_server\Installs$\New_Users\New_users.xls")
intRow = 2
Const ADS_UF_ACCOUNTDISABLE = 2
Const ADS_PROPERTY_UPDATE = 2
Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25
Do Until objExcel.Cells(intRow,1).Value = ""
y = objExcel.Cells(intRow, 1).Value
x = objExcel.Cells(intRow, 2).Value
u = objExcel.Cells(intRow, 3).Value
v = objExcel.Cells(intRow, 4).Value
z = objExcel.Cells(intRow, 5).Value
w = objExcel.Cells(intRow, 6).Value
q = objExcel.Cells(intRow, 7).Value
intRow = intRow + 1
Set objOU = GetObject("LDAP://ou=" & u & ",dc=domain,dc=com")
Set objUser = objOU.Create("User", "cn=" & y & "." & x)
objUser.Put "sAMAccountName", y & "." & x
objUser.SetInfo
Set objusers = GetObject("LDAP://cn=" & y & "." & x & ",ou=" & u &
",dc=Domain,dc=com")
objusers.SetPassword "defaultpassword"
objusers.Put "pwdLastSet", 0
objusers.Setinfo
intUAC = objUsers.Get("userAccountControl")
If intUAC AND ADS_UF_ACCOUNTDISABLE Then
objUsers.Put "userAccountControl", intUAC XOR ADS_UF_ACCOUNTDISABLE
objusers.Setinfo
End If
objUsers.Put "givenName", y
objUsers.Put "sn", x
objUsers.Put "displayName", y & " " & x
objUsers.Put "mail", y & "." & x & "@Domain.com"
objUsers.Put "UserPrincipalName", y & "." & x & "@Domain.com"
objUsers.Put "Description", v
objUsers.Put "physicalDeliveryOfficeName", w
objUsers.Put "scriptPath", z
objUsers.Put "homeDrive", "G:"
objUsers.Put "homeDirectory", "\\" & w & "\" & y & "." & x & "$"
objusers.SetInfo
If q = "Location1" Then
r = " (Mailbox store1)"
ElseIf q = "Location2" Then
r = " (Mailbox store2)"
Else r = ""
End If
If q = "JLocation1" Then
t = "Mailbox Store"
ElseIf q = "Location2" Then
t = "Mailbox Store"
Else t = "Branch Users"
End If
If q = "Jericho" Then
s = "exchangeserver2"
ElseIf q = "location2" Then
s = "exchangeserver1"
Else s = "exchangeserver1"
End If
Dim oIADSUser
Dim oMailbox
Set oIADS = GetObject("LDAP://RootDSE")
'strDefaultNC = oIADS.Get("defaultnamingcontext")
Set oIADSUser = GetObject("LDAP://CN=" & y & "." & x & ",ou=" & u & "," &
"DC=Domain,DC=COM")
Set oMailBox = oIADSUser
Set oIADS = GetObject("LDAP://RootDSE")
oMailBox.CreateMailbox _
"LDAP://" & _
"CN=" & t & r & _
",CN=" & "First Storage Group" & ",CN=InformationStore" & _
",CN=" & s & ", CN=Servers" & _
",CN=Mail, CN=Administrative Groups" & _
",CN=" & "Microsoft Exchange" & ",CN=Microsoft Exchange,CN=Services" & _
",CN=Configuration,DC=Domain,DC=COM"
oIADSUser.SetInfo
ParentFolder = "\\" & w & "\users$\"
set objShell = CreateObject("Shell.Application")
set objFolder = objShell.NameSpace(ParentFolder)
objFolder.NewFolder y & "." & x & "$"
strComputer = W
Set objWMIService = GetObject ("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNewShare = objWMIService.Get("Win32_Share")
errReturn = objNewShare.Create ("d:\users\" & y & "." & x & "$", y & "." &
x & "$", FILE_SHARE, MAXIMUM_CONNECTIONS, v)
Loop
objExcel.Quit
USER_FILE = "\\Server\Installs$\New_Users\New_users.xls"
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "ITHeldesk"
objEmail.To = "serverinfoDomain.com"
objEmail.Subject = "Users Created"
objEmail.Textbody = "The attached spreadsheet contains a list of users that
have just been created"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"emailserver"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.AddAttachment USER_FILE
objEmail.Configuration.Fields.Update
objEmail.Send
> I need to create user accounts for a large number of users. If
> I have an exel file containing username,logon name,password in
> 3 columns how do I read them using an script.
Hi,
See the "Create Users" script here for a script that uses Excel
to create users:
http://www.rlmueller.net/freecode4.htm
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx