Saturday, April 27, 2013

How to Create Bulk user account in Active Directory by using Powershell.


Create AD multiple user accounts by using PowerShell

Many times we come across a scenario where we need to create bulk of AD user accounts. As an Expert we came up with an idea went ahead and made a PowerShell Script that will create users from a CSV file. Hope you find it useful!!!!

We have tested the below script in Windows Server 2008 R2 AD infrastructure.


We have created a test OU as ChennaiUsers in our Learnexchange2013.com with no users.
 
 
 


Below is the Power shell script in text format to create bulk users in AD.
 
 

The Script data is below, copy the below text into Notepad and save it as AccountCreate.ps1

Import-Csv \.AccountCreate.Csv | foreach-Object {$Userprincipalname =$_.samAccountName + "@learnexchange2013.com"
New-ADuser -Name $_.firstName -surname $_.lastname -samaccountname $_.samaccountname -userprincipalname $_.userprincipalname -path $_.path -accountpassword (convertTo-secureString "U@se123r" -asplaintext -force) -Enabled $true}



Create User account Properties details in CSV format as per below..
 

 
 

Save the file details in CSV format as per below..Copy both above files in the same location.

Open Active Directory Power shell and navigate to above location and execute the .ps1
 

 
 
 
 

 

No comments:

Post a Comment