31.8 C
Dubai
Thursday, August 18, 2022
spot_img

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
Specialized in Microsoft Azure - Office 365 / Microsoft Exchange; conducted numerous projects worldwide in designing, supporting, and implementing messaging and virtualization infrastructure for medium-sized and large enterprises. Further, I am a Cloud Architect and Technical Advisor for various start-ups.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here