Solved

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

Posted on 2006-06-27
10
272 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I guess it is not common knowledge to most Wintel engineers/administrators: If you have an SNMP-based monitoring system in your environment (and it's common to have SNMP or Syslog) it's reasonably easy to enable monitoring of the Windows Event logs,…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now