itguy22 Posted June 1, 2015 Posted June 1, 2015 Does anybody know of any free tools that can create multiple AD users in AD 2012R2 for example using a CSV? It is to create user accounts for a new intake of pupils? Thanks.
halbaradkenafin Posted June 1, 2015 Posted June 1, 2015 (edited) Powershell is your friend for this. I'll post my script in a minute. Edit: Here is my code, you'll need to customise a few things for your domain but it should be pretty easy to just drop it into notepad and save it as a .ps1 and run from a powershell prompt. ################################################ # Script to add new users to AD # Call from Powershell window with -Path option # Directed to the csv file to import # Example CSV file in the folder # # Also adds users to Intake Security Group # ################################################ param( [Parameter(Mandatory=$true)][string]$Path = $(Read-Host -Prompt "Enter the path to the csv") ) Function Check-ADUser { [string]$Name = $args[0] $ADUser = Get-ADUser -Filter {SamAccountName -eq $Name} if ($ADUser) { return $ADUser.SamAccountName } else { return 0 } } $Users = Import-Csv -Path $Path Write-Output -InputObject "Forename, Surname, Username, Password" >> "NewUsersCreated.csv" foreach ($User in $Users) { $ShortName = ($User.Forename).Substring(0,1) + "." + $User.Surname $IsADUser = Check-ADUser $ShortName $Count = 1 while ($IsADUser -ne 0) { $ShortName = ($User.Forename).Substring(0,1) + "." + $User.Surname + "$Count" $IsADUser = Check-ADUser $ShortName $Count += 1 } $DisplayName = $User.forename + " " + $User.surname $SecureString = ConvertTo-SecureString -String $User.Password -AsPlainText -Force $HomeDirectory = "\\fileserver\share\" + $User.intakeyear + "\" + $ShortName $ProfilePath = "\\fileserver\share\" + $User.intakeyear + "\" + $ShortName $UserPrincipalName = $ShortName + "@domain.local" $email = $ShortName + "@domain.local" New-ADUser -Name $ShortName -Description $User.description -DisplayName $DisplayName -GivenName $User.forename -HomeDirectory $HomeDirectory -HomeDrive "N:" -ProfilePath $ProfilePath -SamAccountName $ShortName -Surname $user.surname -UserPrincipalName $UserPrincipalName -Path $User.OU -AccountPassword $SecureString -EmailAddress $email -Enabled 1 -ChangePasswordAtLogon 1 Start-Sleep -s 10 Add-ADGroupMember -Identity $User.intakeyear -Member $ShortName Write-Output -InputObject "$Forename, $Surname, $ShortName,$($User.password)" >> "NewYearUsersCreated.csv" } You might not use all the things there, like Profile Path and Home Path but it's just a case of removing the variable declaration and then removing it from the New-ADUser section too. The script will dump out a csv containing all the usernames and passwords as it will automatically create usernames with the next available username, such as J.Smith1 if there is already a J.Smith. Edited June 1, 2015 by halbaradkenafin
mrbios Posted June 1, 2015 Posted June 1, 2015 I use this every year: Dovestones Software Active Directory User Import - AD Bulk Users 1
halbaradkenafin Posted June 1, 2015 Posted June 1, 2015 Looks good, do you have a sample CSV? forename,surname,initial,OU,description,password,intakeyear test,user,t,"OU=IntakeYear,OU=Students,DC=Domain,DC=local",Student Test,"Password1",2014 1
SHimmer45 Posted June 1, 2015 Posted June 1, 2015 the $."somename" would need to match the 1st cell in the column of you CSV iirc i use this for creating users currently Import-Csv D:\users.csv | Foreach-object { New-ADUser -Name $_.DisplayName -UserPrincipalName $_.UserPrincipalName -SamAccountName $_.Username -GivenName $_.GivenName -DisplayName $_.DisplayName -Surname $_.Surname -Description $_.Description -Path $_.Path -ScriptPath $_.ScriptPath -HomeDirectory $_.Homedirectory -HomeDrive $_.HomeDrive -AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -Force) -Enabled $True -PasswordNeverExpires $True -PassThru } 1st time doing it using powershell so i have kept it as simple as possible. my CSV headers are Username,GivenName,Surname,DisplayName,UserPrincipalName,Password,Description,HomeDirectory,HomeDrive,ScriptPath,Path
halbaradkenafin Posted June 1, 2015 Posted June 1, 2015 the $."somename" would need to match the 1st cell in the column of you CSV iirc As long as it matches a column name it doesn't matter which order they are in. I'm doing basically the same thing as you with a bit of error checking and creating paths etc to save the amount of information I put into the csv, so I can pretty much just get the csv from the MIS team add a column for password/intake year and import it.
itguy22 Posted June 1, 2015 Author Posted June 1, 2015 Just another thumbs up for dovestone. It says this is a trial? It is time limited?
zag Posted June 1, 2015 Posted June 1, 2015 No idea, we bought it about 7 years ago. It was incredibly cheap I seam to remember.
kennysarmy Posted June 1, 2015 Posted June 1, 2015 I've used Active User Manager V1.2.7 in the past then a series of batch files to create home drives, shares, permissions etc.
stitch Posted June 1, 2015 Posted June 1, 2015 Just another thumbs up for dovestone. Great software and reasonably priced
NewFormz Posted June 1, 2015 Posted June 1, 2015 If you are looking for a free solution I would recommend Wisesoft Bulk AD Users. I've used it for years and it works great, you create everything in Excel then it does the rest of the work for you.
Sephiroth Posted June 1, 2015 Posted June 1, 2015 I agree with the notion of Powershell... Mine is by no means flawless, but I have it run as a scheduled task every night to import a CSV (also scheduled to export every night using SIMS report scheduler) and create every aspect of the account (including file shares, security groups and quotas) before e-mailing the form tutor the name, username and randomly generated password for each account. I can't post the full code here for various reasons (mainly the character limit here ) but if anyone wants to do something specific with relation to user account creation or automation, I'll help where I can.
Boredguy Posted June 1, 2015 Posted June 1, 2015 I agree with the notion of Powershell... Mine is by no means flawless, but I have it run as a scheduled task every night to import a CSV (also scheduled to export every night using SIMS report scheduler) and create every aspect of the account (including file shares, security groups and quotas) before e-mailing the form tutor the name, username and randomly generated password for each account. I can't post the full code here for various reasons (mainly the character limit here ) but if anyone wants to do something specific with relation to user account creation or automation, I'll help where I can. We do pretty much the exact same thing @Sephiroth and it doesn't half save time
IrritableTech Posted June 1, 2015 Posted June 1, 2015 If you are looking for a free solution I would recommend Wisesoft Bulk AD Users. I've used it for years and it works great, you create everything in Excel then it does the rest of the work for you. Yup - I've used this too. The other one is Mikeys Active User Manager - which he released for free in the end. Hard to find now though.
sted Posted June 1, 2015 Posted June 1, 2015 I just wrote a spreadsheet that you just copy n paste the last 2 pages of to notepad and run as a batch file. Simple qorks out usernames for me (so if I have a kid called fred blogs in yoe 2010 it works out username is 0fbloggs etc
Sephiroth Posted June 1, 2015 Posted June 1, 2015 (edited) We do pretty much the exact same thing @Sephiroth and it doesn't half save time To be honest, the main reasons that I wrote this was that, usually, the fist we know of new students is when they turn up at the door needing to log in NOW. That and last year we had an intake of circa 900 (due to SOR) which I didn't want to input manually. As an aside, I'd be interested to compare scripts to see how others do some of the things that I've fudged Edited June 1, 2015 by Sephiroth
SHimmer45 Posted June 1, 2015 Posted June 1, 2015 i only looked at powershell as the DSADD way i was doing things started to give me problems running as batches due to whitespace issues which didnt become apparent until i tried to create the users mailbox....
sted Posted June 1, 2015 Posted June 1, 2015 i only looked at powershell as the DSADD way i was doing things started to give me problems running as batches due to whitespace issues which didnt become apparent until i tried to create the users mailbox.... whitespace as in spacebar characters I just wrap everything in "" 's to get round that one
sted Posted June 1, 2015 Posted June 1, 2015 not sure this is the latest revision but heres a version of my spreadsheet (I think the only revisions ive done recently are to along longer ou paths) users using dsadd v3 inc dollar.xls
SHimmer45 Posted June 1, 2015 Posted June 1, 2015 whitespace as in spacebar characters I just wrap everything in "" 's to get round that one tried that exchange still moaned about trailing whitespace's tbh i might have been how i was creating the CSV in excel and then checking it in notepad and adding corrections where needed. since doing it with powershell i havent bothered with it as its MUCH quicker in powershell
Sephiroth Posted June 1, 2015 Posted June 1, 2015 i was creating the CSV in excel and then checking it in notepad From experience, it is a very bad idea to use Excel to create CSV files as it adds lots of formatting that can kill the file for it's intended purpose. In my example it removes leading zeros from usernames. Obviously not helpful.
SHimmer45 Posted June 1, 2015 Posted June 1, 2015 From experience, it is a very bad idea to use Excel to create CSV files as it adds lots of formatting that can kill the file for it's intended purpose. In my example it removes leading zeros from usernames. Obviously not helpful. done it that way for a long time without issue but its led me to find and use a better method
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now