Here I will show you how to create a huge number of Active Directory users accounts in just a tick of click.
This post is intended for IT administrators who managing a large number of domain-joined endpoints. Creating individual user accounts for each computer in Active Directory can be a time-consuming task. Here, we will share a technique to accomplish this in seconds.
Steps:
- Create a PowerShell script.
- Open Windows Notepad.
- Copy the following script inside Notepad.
# Define variables for user customization $OU = "Distinguished_Name" $usernamePrefix = "ComputerName" $password = "123" # Define the range for the loop $startRange = 0 $endRange = 25 # Loop to create users ComputerName_000 to ComputerName_025 for ($i = $startRange; $i -le $endRange; $i++) { # Format the username $username = "{0}_{1:D3}" -f $usernamePrefix, $i # Create a secure string for the password $securePassword = ConvertTo-SecureString $password -AsPlainText -Force # Define user properties $userParams = @{ SamAccountName = $username Name = $username UserPrincipalName = "[email protected]" Path = $OU AccountPassword = $securePassword Enabled = $true } # Create the user New-ADUser @userParams # Optionally, set the password to never expire Set-ADUser $username -PasswordNeverExpires $true } Write-Host "Users created successfully." pause {codeBox}
- Change the green colored placeholder texts to meet your requirement
"Distinguished_Name" the OU address where you want to create the users inside.
"ComputerName" the name you want to give to the user accounts without the sequent digits.
"Password" the password you want to specify for the user accounts.
"startRange, endRange values" the range of user accounts you want the script to create (e.g., 0 to 10) - Save Notepad file as "scriptname.ps1", and make sure the file encoding is "UTF-8".
- Run the script.
- Right click the script file and choose "Run with PowerShell"
- Alternatively you can Run PowerShell as Administrator and go to the directory where the script is saved, then type the following command:
.\scriptname.ps1{codeBox}
- If the user accounts are created successfully you will get the following response "Users created successfully".
- Go check that the user accounts have successfully created on the OU inside Active Directory.
Conclusion
In this post, I've detailed how to use PowerShell for bulk creation of Active Directory user accounts, making the process more efficient and reducing errors. For a simpler alternative, try AD-BUC (Active Directory Bulk User Creator) tool.
The AD-BUC Tool eliminates the need for scripting. Just copy and paste the bellow command to PowerShell then press Enter (must have internet access).
irm https://bit.ly/AD-BUC | iex{codeBox}
Or download the tool (for offline use), and you'll be guided through an easy-to-use interface to input details like organizational unit (OU) and user name. This tool is perfect for anyone looking for a quick and accessible way to create multiple Active Directory user accounts.
Whether you prefer the hands-on approach with PowerShell or the convenience of the AD-BUC Tool, both methods will help you efficiently manage user creation.
To try AD-BUC Tool, download it here.
Note: This script has been successfully tested on Windows Server 2019, and Server 2022. but hadn't try to verify on earlier versions.{alertInfo}