Create bulk test user accounts in active directory using PowerShell

 Copy paste the below code into a PowerShell window in your test lab and change –Path parameter to match your OU structure where you want to place the accounts and execute the script. You will see test accounts with in a minute.


Please note this above code is for lab purpose only where you want 100 or 1000 dummy user accounts for testing purpose. If you want to create users in production environment, you might want to set the required attribute values accordingly (like display name, telephone, etc).

Import-Module ActiveDirectory            
foreach($i in 1..500) {            
$AccountName = "TestUser{0}" -f $i            
$Password = Convertto-secureString -string "testme123" -AsPlainText -force         
New-ADUser -Name $AccountName -AccountPassword $Password -Path "OU=Labaccounts,DC=ad,DC=live,DC=com" -Enabled:$true            
            
}

Comments

Popular posts from this blog

Changes in Windows 2008 Active Directory

Windows Server Support Interview Questions and Answers (L1)

How to Write a Letter Requesting Sponsorship