In this post, we offer a useful PowerShell script for managing Active Directory (AD) users. Whether you are an IT administrator or a system operator, this script simplifies the process of bulk user creation and can save you significant time.
powershell
# Import Active Directory module
Import-Module ActiveDirectory
# Prepare user data for bulk user creation
$users = @(
@{
SamAccountName = jdoe
GivenName = John
Surname = Doe
UserPrincipalName = [email protected]
Password = P@ssw0rd!
},
@{
SamAccountName = asmith
GivenName = Alice
Surname = Smith
UserPrincipalName = [email protected]
Password = P@ssw0rd!
}
)
# Loop through each user and create in Active Directory
foreach ($user in $users) {
New-ADUser -SamAccountName $user.SamAccountName `
-GivenName $user.GivenName `
-Surname $user.Surname `
-UserPrincipalName $user.UserPrincipalName `
-Name "$($user.GivenName) $($user.Surname)" `
-AccountPassword (ConvertTo-SecureString $user.Password -AsPlainText -Force) `
-Enabled $true
Write-Host "User $($user.SamAccountName) created successfully."
}Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in Active Directory
Active Directory User Onboarding with PowerShell
2026-08-17Active Directory User Offboarding with PowerShell
2026-08-17Disable an Active Directory User with PowerShell
2026-08-17Enable an Active Directory User with PowerShell
2026-08-17Unlock an Active Directory Account with PowerShell
2026-08-17Reset an Active Directory Password with PowerShell
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.