Solved

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

Posted on 2006-06-27
10
277 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
Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.

749 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