30 C
Dubai
Saturday, November 16, 2024

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

Satheshwaran Manoharan
Satheshwaran Manoharanhttps://www.azure365pro.com
Award-winning Technology Leader with a wealth of experience running large teams and diversified industry exposure in cloud computing. From shipping lines to rolling stocks.In-depth expertise in driving cloud adoption strategies and modernizing systems to cloud native. Specialized in Microsoft Cloud, DevOps, and Microsoft 365 Stack and conducted numerous successful projects worldwide. Also, Acting as a Technical Advisor for various start-ups.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?