Script to create bulk users in windows Machine

 

Script for create bulk user in local machine

Login to the machine where you want to create  bulk user.

Open Windows PowerShell ISE


Copy below script and past it in PowerShell ISE like below


function create-account ([string]$accountName) {

 $hostname = hostname

 $comp = [adsi]"WinNT://$hostname"

 $user = $comp.Create("User", $accountName)

 $user.SetPassword("P@ssw0rd")

 #$user.SetInfo()

 $User.UserFlags[0] = $User.UserFlags[0] -bor 0x10000 #ADS_UF_DONT_EXPIRE_PASSWD flag is 0x10000

 $user.SetInfo()}

 # Create 30 administrator users named user1 ... user 30

for($i=23; $i -le 25; $i++){

  create-account("TRAIN-$i")

  } 

  Get-LocalUser -Name TRAIN* | select FullName, Enabled, UserMayChangePassword, PasswordChangeableDate, PasswordExpires | Export-Csv c:\temp\user.csv -NoTypeInformation 


 

 

 


Note -: To change default password, you need to update in script line no 5

             To change number of users that need to create, update in script line no 10

             To change user name or Caps letter you need to update in script line no 11

New users will create and CSV file will export at the below path.

c:\temp\user.csv -NoTypeInformation 


No comments:

Post a Comment

Featured Post

HPE MSA 2040 configuration step by step

HPE MSA 2040 configuration Default IP range for HP SAN storage MSA 2040 is 10.0.0.1/2 You need to connect your laptop and storage with...