Introduction

Creating multiple Active Directory users manually is time-consuming and error-prone. This tutorial shows you how to automate the entire process using PowerShell and a CSV file.

Step 1: Prepare Your CSV File

Create a CSV file named users.csv with these columns:

  • FirstName
  • LastName
  • Username
  • Password
  • Department
  • Title

Step 2: The PowerShell Script

Import-Module ActiveDirectory

$Users = Import-Csv -Path "C:\users.csv"

foreach ($User in $Users) {
    $UserParams = @{
        Name = "$($User.FirstName) $($User.LastName)"
        GivenName = $User.FirstName
        Surname = $User.LastName
        SamAccountName = $User.Username
        UserPrincipalName = "$($User.Username)@yourdomain.com"
        AccountPassword = (ConvertTo-SecureString $User.Password -AsPlainText -Force)
        Enabled = $true
        Department = $User.Department
        Title = $User.Title
        Path = "OU=Users,DC=yourdomain,DC=com"
    }
    
    New-ADUser @UserParams
    Write-Host "Created user: $($User.Username)" -ForegroundColor Green
}

Step 3: Run the Script

Open PowerShell as Administrator and run the script. Each user will be created with all the specified properties.

Pro Tip

Add error handling with Try-Catch blocks to log any failures and continue processing remaining users.