Creating a single Active Directory (AD) account is a simple task. However, in an organization, the number of AD user accounts an administrator would have to create can rise drastically, making the simple task cumbersome. This is where the process of automating this task comes in handy. AD user account creation can be automated using PowerShell easily. The MMC snap-in of the ADUC console can also be used which is an easier method, but it is not the go-to method when it comes to bulk creation. Using PowerShell, the details of users to be created in bulk can be imported from a CSV file which makes the PowerShell method more powerful.
Here's a script where you can import data from a CSV file for AD users in bulk, and create user accounts for the users. The script is for a CSV file that contains the FirstName, LastName, and the UserName. You can add more details as necessary.
Note: The CSV file must be in UTF8 coding.
- Import-Csv -Path 'C:\Employees.csv' | foreach {
- $NewUserParameters = @{
- 'GivenName' = $_.FirstName
- 'Surname' = $_.LastName
- 'Name' = $_.UserName
- 'AccountPassword' = (ConvertTo-SecureString 'p@$$w0rd10' -AsPlainText -Force)
- }
- New-AdUser @NewUserParameters
- }