Import active directory module for running AD cmdlets
Import-Module ActiveDirectory
#Store the data from ADUsers.csv in the $ADUsers variable
$ADUsers = Import-csv C:\temp\email.csv
#Loop through each row containing user details in the CSV file
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
$Fax = $User.Fax
$city = $User.city
$state = $User.state
$title = $User.title
$Department = $User.Department
$Company = $User.Company
$email = $user.email
$Description = $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@prajapati.com" `
-Name "$Firstname $Lastname" `
-GivenName $Firstname `
-Surname $Lastname `
-Enabled $True `
-email $email `
-Description $Description `
-DisplayName "$Firstname $Lastname" `
-Path $OU `
-Fax $Fax `
-City $City `
-State $State `
-title $title `
-Department $Department `
-Company $Company `
-AccountPassword (convertto-securestring $Password -AsPlainText -Force) -ChangePasswordAtLogon $false `
}
}
On this page of the site you can watch the video online How to Create Bulk Active Directory Users Using PowerShell + CSV with a duration of hours minute second in good quality, which was uploaded by the user Vinod Prajapati 05 December 2025, share the link with friends and acquaintances, this video has already been watched 17 times on youtube and it was liked by 2 viewers. Enjoy your viewing!