Need script of batch to create new local admin account

I am wanting to batch create a local admin account on all domain workstations using a batch or script and also set the password for such account.  I would also like to then disable to built-in local admin account on those same machines.
murrycAsked:
Who is Participating?
 
RobSampsonConnect With a Mentor Commented:
Hi, this VBScript should work.

Regards,

Rob.
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
strNewUsername = "Admin2"
strNewPassword = "AdminPass"

Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", strNewUsername)
objUser.SetPassword strNewPassword
objUser.SetInfo

Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group" ) 
objGroup.Add objUser.ADsPath

Set objUser = GetObject("WinNT://" & strComputer & "/Administrator,user")
objUser.AccountDisabled = True
objUser.SetInfo

Open in new window

0
 
murrycAuthor Commented:
How best to run this against all of the computers on the network in a batch execution?  psexec?
0
 
RobSampsonCommented:
Is it possible to assign it as a StartUp script? That would probably be easiest.

Otherwise, yeah, you can use PSExec to run it against a list of computers.

Something like this should work:
psexec @computers.txt -accepteula -u domain\admin -p password wscript.exe //B \\server\share\CreateAdminAccount.vbs

Regards,

Rob.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.