Script to create local admin user

I need a script that determines what domain user is correctly logged in, then creates a local admin for that user.  The users are non-admin in the domain, but they need to be a local domain so that I can make some system tweaks under their profile that require admin privileges.  I then need a script that deletes the local admin user for that domain user as I will need to remove the local account after the tweaks have been completed.
murrycAsked:
Who is Participating?
 
Chris HInfrastructure ManagerCommented:
I hate VB when a batch file will do it.

Batch file 1
set /p pass=Type a Password
net user /add %username% %pass%
net localgroup administrators %username% /add

Batch file 2
net user /delete %username%
0
 
Chris HInfrastructure ManagerCommented:
What OS?
0
 
murrycAuthor Commented:
Windows 7 Pro

I am all for batch files or VB scripts.  Whatever works.

I don't think this batch will add the current logged in user as a local admin though.  There is no need to give it a password as the user is domain existing and so we are just adding them as a local user.  This will be executed on a domain environment.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
Chris HInfrastructure ManagerCommented:
It worked fine, see attached file....
Untitled.png
0
 
Chris HInfrastructure ManagerCommented:
AND ALWAYS PASSWORD PROTECT ADMIN ACCOUNTS.

Sorry, that was my old tech instructor yelling at both of us.
0
 
Chris HInfrastructure ManagerCommented:
Whoops, wrong pic, this one...
Untitled.png
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.