Bulk User Account Creation

This script creates multiple user accounts from a CSV file. Ensure your CSV file (users.csv) has the following headers: FirstName, LastName, Username, and OU.

# Import users from a CSV file
$users = Import-Csv -Path "C:\Path\To\users.csv"

# Loop through each user to create an AD account
foreach ($user in $users) {
    $fullName = "$($user.FirstName) $($user.LastName)"
    $samAccountName = $user.Username
    $ouPath = $user.OU
    $password = ConvertTo-SecureString "P@ssw0rd123" -AsPlainText -Force
    
    # Create the user
    New-ADUser -Name $fullName `
               -GivenName $user.FirstName `
               -Surname $user.LastName `
               -SamAccountName $samAccountName `
               -UserPrincipalName "[email protected]" `
               -Path $ouPath `
               -AccountPassword $password `
               -Enabled $true

    Write-Host "Created account for $fullName"
}

• Modify "C:\Path\To\users.csv" to the actual path of your CSV file.

• Adjust the default password P@ssw0rd123 as required.

Last updated