Script for Creating Bulk Users for Windows Using PowerShell

Sometime when you are working as System Administrator using Microsoft Technology, especially Windows Active Directory, you will have to deploy a user as part of your daily work part.

Even, hundred or thousand. Imagine that you have to do it manually one after the other, then how long it will take to complete whole request as such? two weeks or even a month might be not feasible.

Microsoft comes with PowerShell to ease your pain. It has many features and outstanding app to allow you run custom script as required based on your various condition.

in this post i will explain a little bit about how to provision several users using PowerShell.

1st thing that you have bear in mind PowerShell must be installed in your system prior this script executed. You may install it on your AD server as a best practice.

$Password = “P@ssw0rd.321” #just a initial password, you can enable changepasswordatlogon
$users = Import-Csv -Path “source_file.csv
foreach ($User in $Users)
{
$UPN = $User.name + "@" + "your_domain_name" New-ADUser -Name $User.name -EmailAddress $User.mail -DisplayName $User.name -SamAccountName $User.name -UserPrincipalName $UPN -OfficePhone $User.Phone_Work -Title $User.Title -Department $User.Department -AccountPassword (ConvertTo-SecureString $Password -AsPlainText -Force) -Enabled $true -ChangePasswordAtLogon $False
}

Above script requires you to provide (bold words):

  • Source file with csv format as tabulated below. You can add several users as many as you want

name,mail,phone_work,title,department
John Doe,John.Doe@mail.com,623456789,System Administrator,MIS

  • Your Active Directory FQDN

Once created, the newly created user will be located into Users OU. Please check on Active Directory Users and Computers feature on your AD server.

Hope this article useful.

One thought on “Script for Creating Bulk Users for Windows Using PowerShell

Leave a Reply

Your email address will not be published. Required fields are marked *