It is fairly easy to crete a domain user but how about if you are supposed to create 800 new users. It is possible to create hundres of users in a few minutes with powershell. This article describes how to implement such a scenario.

 

In this lab, Active Directory Operating System is Windows Server 2008R2 .

 

Scenario: We are going to create New Student Accounts for our university. Students' registration years are 2010, 2011, 2012 and this information is in a excel document. 

 

First create OUs like below and also create corresponding security groups (9 groups will be created in this example like Sosyoloji2010, Sosyoloji2011 and so on)

zubik.local/MainOffice/Users/Students/MuhendislikFakultesi/EndustriMuhendisligi/2010

zubik.local/MainOffice/Users/Students/MuhendislikFakultesi/EndustriMuhendisligi/2011

zubik.local/MainOffice/Users/Students/MuhendislikFakultesi/EndustriMuhendisligi/2012

zubik.local/MainOffice/Users/Students/IletisimFakultesi/RadyoSinema/2010

zubik.local/MainOffice/Users/Students/IletisimFakultesi/RadyoSinema/2011

zubik.local/MainOffice/Users/Students/IletisimFakultesi/RadyoSinema/2012

zubik.local/MainOffice/Users/Students/SosyalBilimlerFakultesi/Sosyoloji/2010

zubik.local/MainOffice/Users/Students/SosyalBilimlerFakultesi/Sosyoloji/2011

zubik.local/MainOffice/Users/Students/SosyalBilimlerFakultesi/Sosyoloji/2012

 

Edit your excel file and change the column titles as below. Some cells have formulas.

Formulas that I used:

Email: =I2&"@zubik.com"

OU: =CONCATENATE(E2, "/", F2, "/", G2)

Logon Username: =LOWER(A2&B2)

Name: =(A2) &" "& (B2)

Container: =CONCATENATE("zubik.local/MainOffice/Users/Students/", H2)

 

Sample Excel File can be downloaded.

 

 

 

We need to create CSV file. File/SaveAs.

FileName: NewUsers.csv

Save As Type: CSV Commadelimited  

 

Active (Sheet2) will not be in CSV, so it is warning about it. Click OK.

 

Yes. 

 

Close Excel and select Save.

 

Check your CSV file, there should be comma between the values. If you see semicolon instead of comma. Open Control Panel/Regional Settings/Change Date Time Format/Additional Setting and change List Seperator to comma. Also change decimal symbol to semicolon. Then create your CSV and check again your CSV file.

 

Now create the script in notepad, name it to  Add-NewUsers.ps1. Change its extension as ps1 when you are finished with it.

 

Dont forget to change the domainin your script.   

By using Add-QADGroupMember command, we add the user to the desired security group (Sosyoloji, EndustriMuhendisligi or RadyoSinema).


##########################################
Import-Csv "NewUsers.csv" | ForEach-Object {
    $userPrinc = $_."Logon Username" + "@zubik.local"
    New-QADUser -Name $_.Name `
        -ParentContainer $_."Container" `
        -SamAccountName $_."Logon Username" `
        -UserPassword $_."Password" `
        -FirstName $_."First Name" `
        -LastName $_."Last Name" `
		-Email $_."Email" `
        -Description $_."Bolum" `
        -UserPrincipalName $userPrinc `
        -DisplayName $_."Name" ;`
    Add-QADGroupMember -identity $_."Bolum" -Member $_."Logon Username" ;`
    Set-QADUser -identity $_."Logon Username" `
        -UserMustChangePassword $false `
		-PasswordNeverExpires $true `
}
############################################

We have 2 files. Add-NewUsers.ps1 and NewUsers.csv.  Create a folder named bin under C and copy Add-NewUsers.ps1 and NewUsers.csv in bin folder.

 

Run Windows Powershelli as Administrator

 

Run Set-ExecutionPolicy Unrestricted command, so Unsigned scripts can run.

 

Then Add-PSSnapin Quest.ActiveRoles.ADManagement command. So Quest ActiveRoles ADManagement Powershell Snapin commands can be used in powershell. 

 

And Finally run

.\Add-NewUsers.ps1 command to create users.

When process is completed, you might not see the new users in OUs. Refresh the OU and you will see your new users.

 

 

 

 

ennlfrdeitptruestr

Hylafax Installation on Debian

Easy to start HylaFAX is a free linux-based fax server. It is used by many companies worldwide. In this article, we are going to install and configure HylaFAX.

More...

Creating Multiple Users on Active Directory

Docs / SupportIf you are working in an organization which receives a lot new users on several periods of the year, then you should handle creation of domain users  with the help of Powershell. 

More...

How To Change Default Computer OU

Native RTL SupportWhen you join a computer to the domain, Computer Object is created and placed in Default Computer Container which is not an organizational unit and we all know that, GPOs can be only applied to Organizational Units. 

More...

JSN Epic template designed by JoomlaShine.com