One of the biggest challenges for IT administrators to Active Directory bulk user creation. Using the native Active Directory (AD) tools or PowerShell scripts to set each user and configure their properties in AD is a time-consuming task.

We can use PowerShell scripts to create users in bulk from a CSV file and it can save a lot of time compared to manually. Here is a sample CSV file that can be used along with the Powershell script.

Powershell script:

Import-Module ActiveDirectory
ADUsers = Import-CSV c:\ad_data\bulk_users.csv
foreach ($User in $ADUsers)
{
#Read user data from each field in each row and assign the data to a variable as below
$Username  = $User.username
$Password  = $User.password
$Firstname     = $User.firstname
$Lastname  = $User.lastname
$OU        = $User.ou #This field refers to the OU the user account is to be created in
$email      = $User.email
$streetaddress = $User.streetaddress
$city       = $User.city
$zipcode    = $User.zipcode
$state      = $User.state
$country    = $User.country
$telephone  = $User.telephone
$jobtitle   = $User.jobtitle
$company    = $User.company
$department = $User.department
$Password = $User.Password
$descriptionn = $user.description


#Check to see if the user already exists in AD
if (Get-ADUser -F {SamAccountName -eq $Username})
{
     #If user does exist, give a warning
     Write-Warning "A user account with username $Username already exist in Active Directory."
}
else
{
    #User does not exist then proceed to create the new user account

    #Account will be created in the OU provided by the $OU variable read from the CSV file
    New-ADUser `
        -SamAccountName $Username `
        -UserPrincipalName "$Username@infoalias.local" `
        -Name "$Firstname $Lastname" `
        -GivenName $Firstname `
        -Surname $Lastname `
        -Enabled $True `
        -DisplayName "$Firstname $Lastname" `
        -Path $OU `
        -City $city `
        -Company $company `
        -State $state `
        -StreetAddress $streetaddress `
        -OfficePhone $telephone `
        -EmailAddress $email `
        -Title $jobtitle `
        -Department $department `
        -AccountPassword (convertto-securestring $Password -AsPlainText -Force) -ChangePasswordAtLogon $True

}


}

By amit_g

Welcome to my IT Infra Blog! My name is Amit Kumar, and I am an IT infrastructure expert with over 11 years of experience in the field. Throughout my career, I have worked with a wide variety of systems and technologies, from network infrastructure and cloud computing to hardware and software development. On this blog, I aim to share my knowledge, insights, and opinions on all things related to IT infrastructure. From industry trends and best practices to tips and tricks for managing complex systems, my goal is to provide valuable information that will help IT professionals and enthusiasts alike. Whether you are a seasoned IT veteran or just getting started in the field, I hope you will find my blog to be a valuable resource. In addition to sharing my own thoughts and ideas, I also welcome feedback, comments, and questions from my readers. I believe that a collaborative approach is the best way to advance the field of IT infrastructure and I look forward to hearing from you. Thank you for visiting my blog, and I hope you will continue to follow along as I explore the fascinating world of IT infrastructure. Sincerely, Amit Kumar

3 thoughts on “Create Bulk Users in Active Directory”
  1. Very useful video and site. Thank you : )
    To get it to work I had to amend Line 2 in above script from:
    ADUsers = Import-CSV c:\ad_data\bulk_users.csv
    to:
    $ADUsers = Import-CSV c:\ad_data\bulk_users.csv

Leave a Reply

Your email address will not be published. Required fields are marked *