Earl28
asked on
Adding Bulk Users in AD
I am trying to find a good way to add bulk users in AD. I know it can be scripted in powershell but I havent had much luck with that.
I just want to add users, drop them in an OU, set the password and force them to change it at login.
What is the best way to do this, Powershell? If so, how do you do it in powershell?
This is a Windows 2k8 domain, domain fucntional level at 2k3.
TIA
I just want to add users, drop them in an OU, set the password and force them to change it at login.
What is the best way to do this, Powershell? If so, how do you do it in powershell?
This is a Windows 2k8 domain, domain fucntional level at 2k3.
TIA
I searched a lot and didn't find anything; you can have a look:
https://www.experts-exchange.com/questions/27798291/Create-Users-daily-in-Active-Directory-AD.html
Now we use ADConnector:
http://www.itrainlabs.ch/en/adconnector.html
http://www.itrainlabs.ch/en/adconnector/presentation.html
http://www.itrainlabs.ch/en/adconnector/technical-videos.html
Demo:
http://www.itrainlabs.ch/en/adconnector/online-test-drive.html
https://www.experts-exchange.com/questions/27798291/Create-Users-daily-in-Active-Directory-AD.html
Now we use ADConnector:
http://www.itrainlabs.ch/en/adconnector.html
http://www.itrainlabs.ch/en/adconnector/presentation.html
http://www.itrainlabs.ch/en/adconnector/technical-videos.html
Demo:
http://www.itrainlabs.ch/en/adconnector/online-test-drive.html
What format do you have the users details in?
ASKER
CSV, and its just FirstName,LastName.
ASKER
Here is what I have, I ripped it off some site, so I didnt write it. (disclaimer)
$objOU=[ADSI]"LDAP://OU=Ne wUserDump, OU=CCA Campus,DC=mydomain,DC=loca l"
$dataSource=import-csv "adduser.csv"
foreach($dataRecord in $datasource) {
$cn=$dataRecord.FirstName + " " + $dataRecord.Lastname
$SAMAccountName=$dataRecor d.FirstNam e + "." + $datarecord.LastName
$givenName=$dataRecord.Fir stName
$sn=$dataRecord.LastName
$SAMAccountName=$SAMAccoun tName.ToLo wer()
$displayName=$sn + ", " + $givenName
$userPrincipalName=$SAMAcc ountName + "@mydomain.local"
$objUser=$objOU.Create("us er", "CN="+$cn)
$objUser.Put("SAMAccountNa me",$SAMAc countName)
$objUser.Put("userPrincipl aName",$us erPrincipa lName)
$objUser.Put("dispalyname" ,$displayN ame)
$objUser.Put("givenName",$ givenName)
$objUser.Put("sn",$sn)
$objUser.SetInfo()
$objUser.SetPassword("pass word")
$objUser.psbase.InvokeSet( "AccountDi sabled",$f alse)
$objUser.SetInfo()
}
When I run it in powershell, it doesnt like the last 4 lines, in regard to the password. I removed those lines, the script ran without error, but no user account was created in the specified OU.
I am running the script as Admin in Powershell and have changed the ExecutionPolicy.
$objOU=[ADSI]"LDAP://OU=Ne
$dataSource=import-csv "adduser.csv"
foreach($dataRecord in $datasource) {
$cn=$dataRecord.FirstName + " " + $dataRecord.Lastname
$SAMAccountName=$dataRecor
$givenName=$dataRecord.Fir
$sn=$dataRecord.LastName
$SAMAccountName=$SAMAccoun
$displayName=$sn + ", " + $givenName
$userPrincipalName=$SAMAcc
$objUser=$objOU.Create("us
$objUser.Put("SAMAccountNa
$objUser.Put("userPrincipl
$objUser.Put("dispalyname"
$objUser.Put("givenName",$
$objUser.Put("sn",$sn)
$objUser.SetInfo()
$objUser.SetPassword("pass
$objUser.psbase.InvokeSet(
$objUser.SetInfo()
}
When I run it in powershell, it doesnt like the last 4 lines, in regard to the password. I removed those lines, the script ran without error, but no user account was created in the specified OU.
I am running the script as Admin in Powershell and have changed the ExecutionPolicy.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can also use CSVDE -I switch.
This will create users from a standard csv file. It is part of windows.
http://technet.microsoft.com/en-us/library/cc732101(v=ws.10).aspx
I find it is a bit more straight forward, but learning PS is not a bad way to import and learn scripting.
This will create users from a standard csv file. It is part of windows.
http://technet.microsoft.com/en-us/library/cc732101(v=ws.10).aspx
I find it is a bit more straight forward, but learning PS is not a bad way to import and learn scripting.
We created with CSV, but I think you can choose a format.
You haven't referenced the ou in the create function. You only fill a variable with the ou info..
also its much easier you use the built in function..
new-ADUser
http://technet.microsoft.com/en-us/library/ee617253.aspx
also its much easier you use the built in function..
new-ADUser
http://technet.microsoft.com/en-us/library/ee617253.aspx
There are lots of free tools available - why re-invent the wheal
eg http://ad-bulk-users.software.informer.com/
eg http://ad-bulk-users.software.informer.com/
Creating bulk Active Directory user and group accounts in PowerShell using Server 2008 R2 cmdlet
http://get-spscripts.com/2011/08/creating-bulk-active-directory-user-and.html
Creating groups and assigning members
- Rancy
http://get-spscripts.com/2011/08/creating-bulk-active-directory-user-and.html
Sub-TopicsTo create my users in the OU “*****” for the domain “****.local”
Creating groups and assigning members
- Rancy
You can also use batch.
Fire the command dsadd user /? and see what's possible. Try using a for loop on your .csv/textfile.
Fire the command dsadd user /? and see what's possible. Try using a for loop on your .csv/textfile.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all the input. I ended up using the ANUC tool that dreik mentioned. It was good, the CSV part was a bit flaky, so I added them manually using the tool. It took me 2 hours to add 500 users, so not bad.<br /><br />it doesnt allow you to add group membership, if it had that it would be great.<br /><br />Thanks again.
There are a lot of tutorials how much do you know about powershell