Powershell: Create 1000 AD test users

Sometimes you need to test something in your lab and you need a 1000 test users.  For this, I created a simple Powershell script. Feel free to use.

Make sure to set the correct variables and that the OU exists!

Import-Module ActiveDirectory
//Variables
$OU = "OU=TestUsers,DC=VirtualHike,DC=Internal"
$Domain = "virtualhike.internal"
$total = 1000

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

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

  New-ADUser `
   -AccountPassword (ConvertTo-SecureString "AAaaAAaa11!!11" -AsPlainText -Force) `
   -City "Amsterdam" `
   -Company "VirtualHike" `
   -Country "NL" `
   -Department "HomeLAB" `
   -Description ("TEST ACCOUNT " + $userID + ": This is a test account. Not a real user!")`
   -DisplayName "Test User ($userID)" `
   -Division "IT" `
   -EmailAddress "$userName@$Domain" `
    -EmployeeNumber "$userID" `
   -EmployeeID "ISED$userID" `
   -Enabled $true `
   -Fax "12345-$userID" `
   -GivenName "Test" `
   -HomePhone "12345-$userID" `
   -Initials "TU$userID" `
   -MobilePhone "12345-$userID" `
   -Name "Test User ($userID)" `
   -Office "Office: $userID"`
   -OfficePhone "12345-$userID" `
   -Organization "IT" `
   -Path $OU `
   -POBox "PO Box $userID"`
   -PostalCode $userID `a
   -SamAccountName $userName `
   -State "Noord Brabant" `
   -StreetAddress "$userID Sherwood" `
   -Surname "User ($userID)" `
   -Title "Title" `
   -UserPrincipalName "$userName@$Domain"
 }

About Michael
Michael Wilmsen is a experienced VMware Architect with more than 20 years in the IT industry. Main focus is VMware vSphere, Horizon View and Hyper Converged with a deep interest into performance and architecture. Michael is VCDX 210 certified, has been rewarded with the vExpert title from 2011, Nutanix Tech Champion and a Nutanix Platform Professional.

RSS feed for comments on this post.

Leave a Reply

You must be logged in to post a comment.