Powershell: Create 1000 Test User Accounts

For those looking for populate a test domain -- oooh with say a 1000 users with distinct user attribute values -- here is a script that I think will do you just fine: 


Import-Module ActiveDirectory

 $total = 1000
 for ($userIndex=0; $userIndex -lt $total; $userIndex++)
  $userID = "{0:0000}" -f ($userIndex + 1)
  $userName = "test.user$userID"

  Write-Host "Creating user" ($userIndex + 1) "of" $total ":" $userName

  New-ADUser `
   -AccountPassword (ConvertTo-SecureString "AAaaAAaa11!!11" -AsPlainText -Force) `
   -City "City" `
   -Company "Company" `
   -Country "US" `
   -Department "Department" `
   -Description ("TEST ACCOUNT " + $userID + ": This user account does not represent a real user and is meant for test purposes only")`
   -DisplayName "Test User ($userID)" `
   -Division "Division" `
   -EmailAddress "$userName@karchworld.local" `
    -EmployeeNumber "$userID" `
   -EmployeeID "ISED$userID" `
   -Enabled $true `
   -Fax "703-555-$userID" `
   -GivenName "Test" `
   -HomePhone "703-556-$userID" `
   -Initials "TU$userID" `
   -MobilePhone "703-557-$userID" `
   -Name "Test User ($userID)" `
   -Office "Office: $userID"`
   -OfficePhone "703-558-$userID" `
   -Organization "Organization" `
   -POBox "PO Box $userID"`
   -PostalCode $userID `
   -SamAccountName $userName `
   -State "VA - Virginia" `
   -StreetAddress "$userID Any Street" `
   -Surname "User ($userID)" `
   -Title "Title" `
   -UserPrincipalName "$userName@karchworld.local"

Comments (4)
  1. Hi,

    what about if I want to create 100.000 users or even more? Your script than runs on an error. Any idea how to do that for testing purposes?



  2. Bruno says:

    Small typo in:


    There's an extra comma after Users

    Thanks for the script, just helped me in a lab 🙂

  3. Zoe says:

    Should also read -Path "CN=Users,DC=yourdomain,DC=local"

  4. Arman K says:

    This script will run standalone ?? Like do we need any csv file or not ??

    Coz i tried to use this script and i am getting errors like command not found, object not found, etc etc

Comments are closed.

Skip to main content