Creating 150 Active Directory users quickly using a script

Requirement – They want to create 150 Active Directory users with username and password being the same.

Login to Active Directory Server (Domain Controller) Save below to .ps1 , Open Active Directory Power shell,  You can customize as per your wish.

Note:This forest doesn’t have strict password policy.It allows simple passwords. If you want to use a common password for all the users you can save $randompassword = “somepass” and use it after Convertto-securestring replacing $name.

 

$numberofusers = "125"

$Prefix = "Labuser"

$Suffix = "@domain.local"

$pathOU = “OU=Lab,DC=Dubai,DC=com”

For($i=1;$i -le $numberofusers;$i++)

{

$UPN = "$Prefix"+"$i"+"$Suffix"

$Name = "$Prefix"+"$i"

$Password = Convertto-SecureString "$name" -Asplaintext -Force

New-ADUser -Name $Name -SamAccountName $Name -Path $pathOU -UserPrincipalName $UPN -Enabled $True -AccountPassword $Password -PasswordNeverExpires $True -CannotChangePassword $True -verbose

}

 

Sample Screenshots –

Active Directory Powershell –

image

Active Directory Users and Computers –

image

About Satheshwaran Manoharan

Satheshwaran Manoharan is an Microsoft Office Server and Services MVP , Publisher of Azure365pro.com. Specialized in Office365 / Microsoft Exchange / Virtualization , Sathesh is an Messaging Expert supporting/Designing/Deploying many medium size businesses to large enterprises when it comes to Corporate messaging and Virtualization Infrastructure

Check Also

az Git Terraform configs to work behind Proxy

Let’s see how to configure proxy for az Git and Terraform behind an authenticated proxy …

Leave a Reply

Your email address will not be published.