Solved

How can I create and add a Local Admin to 2000 and XP Machines via Script?

Posted on 2006-06-27
10
275 Views
Last Modified: 2010-04-18
I want to create a generic User acct that is not on the domain and assign it to the local admins group on each computer and assign it a password "x" that does not change? How can I accomplish this task? the script will be applied Via GPO .
0
Comment
Question by:tattsnyc
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 51

Accepted Solution

by:
Netman66 earned 250 total points
ID: 16994164
Place this in your CMD file:

net user Admin Password1 /ADD
net localgroup Administrators Admin /ADD


Replace Password1 with a password of your choice.
Replace Admin with the username of your choice.

0
 
LVL 70

Assisted Solution

by:Chris Dent
Chris Dent earned 250 total points
ID: 16994223

Happy with VbScript? All commented, just yell if it's not clear.

Chris


Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000

strUserName = "AdminUser"
strPassword = "AdminPassword1"

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

booExists = False
Set objComputer = GetObject("WinNT://" & strComputer)
For Each objUser In objComputer

      ' If the user exists then just change the password to the one we like

      If (LCase(objUser.Name) = LCase(strUserName)) Then
            booExists = True
            objUser.SetPassword strPassword
            objUser.SetInfo
      End If
Next

' If it doesn't exist create the user and set the password.

If booExists = False Then
      Set objUser = objComputer.Create("user", strUserName)
      objUser.SetPassword strPassword
      objUser.SetInfo

      Set objUser = GetObject("WinNT://" & strComputer & "/" & strUserName & ",user")
      objUser.Description = "Admin Account"

      ' Set the Password to Never Expire

      If Not objUser.UserFlags AND ADS_UF_DONT_EXPIRE_PASSWD Then
            intUserFlags = objUser.UserFlags XOr ADS_UF_DONT_EXPIRE_PASSWD
            objUser.Put "userFlags", intUserFlags
      End If
      objUser.SetInfo

      ' Add the user to the Administrators Group

      Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators, group")
      objGroup.Add(objUser.ADsPath)
      Set objGroup = Nothing
      Set objUser = Nothing
End If
0
 
LVL 51

Expert Comment

by:Netman66
ID: 16994244
Nice script Chris.

Kinda makes me laugh a bit though - it's like the difference between mine in English and yours being the French translation!

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 70

Expert Comment

by:Chris Dent
ID: 16994717

Hehe I see what you mean, the only difference is the password never expires thing, and that's hardly a huge chunk.

I kind of stopped bothering to learn dos commands so half the stuff I do could probably be done in a few lines if I learnt that too :)

Chris
0
 
LVL 16

Expert Comment

by:kshays
ID: 16995468
There are plenty of dos commands for a system admin especially if you utilize the resource kit.  I do think both vbscript and dos commands have a place for in any sys admins library, sometimes it's just easier to do it the old school way :)

Then again you can do some things with vbscript i'm sure that you cannot do with dos commands.

just my two scents on the subject :)

0
 

Author Comment

by:tattsnyc
ID: 16995500
I want to split the points between the first two commenters any objections? thanks for all you help
0
 
LVL 16

Expert Comment

by:kshays
ID: 16995516
I would probably split points between netman66 and chris-dent as well tattsync.  Seems like the only fair thing to do really since both posted a solution that would fit your needs either way and the time was so close to each other.
0
 
LVL 51

Expert Comment

by:Netman66
ID: 16996273
I have no problem with that.
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 16996944

No problems here either :)

Chris
0
 

Author Comment

by:tattsnyc
ID: 17156116
sorry about the dely. I  am so busy I forgot.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question