Solved

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

Posted on 2006-06-27
10
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 71

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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 71

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 71

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Server Login Issue 4 71
SolarWind and DNS Server 12 107
Connecting two servers 30 93
Intel Server Board SE7525GP2 Doesn't Recognize Full Hard Drive Capacity 4 145
Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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