Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

service account

1 view
Skip to first unread message

dustin

unread,
Jan 19, 2004, 3:33:59 PM1/19/04
to
Is there an easy script that will create a local admin
account on all the computers in an OU?

dustin

Torgeir Bakken (MVP)

unread,
Jan 19, 2004, 7:23:44 PM1/19/04
to
dustin wrote:

> Is there an easy script that will create a local admin
> account on all the computers in an OU?

Hi

You could do it in a computer startup script (with a GPO linked to your OU)
that runs as part of the boot up process (before the user logs in). It runs
under the system context and has admin rights.


VBScript example, using the WinNT ADSI provider, creating a new
*local* user and adding him to the "Administrators" group
(more links to documentation/examples at the bottom):


sNewUser = "mini-strator"
sGroupname = "Administrators"

Set oWshNet = CreateObject("WScript.Network")
sComputerName = oWshNet.ComputerName

Set oComputer = GetObject("WinNT://" & sComputerName)
Set oUser = oComputer.Create("user", sNewUser)

On Error Resume Next
' save the user
oUser.Setinfo

' If user exists already, we get an error
If Err.Number = 0 Then
On Error Goto 0
oUser.SetPassword "1234"
' set "User Must Change Password at Next Logon" status
oUser.Put "PasswordExpired", 1

oUser.Fullname = "John Doe"
oUser.Description = "hi!"
oUser.Setinfo
End If
On Error Goto 0


' Add the user to the group
Set oGroup = GetObject("WinNT://" & sComputerName & "/" & sGroupname)

' Use error handling in case he is a member already
On Error Resume Next
oGroup.Add(oUser.ADsPath)
On Error Goto 0


More links:

Configuring a Local User Account So It Never Expires
http://www.microsoft.com/technet/scriptcenter/user/scrug115.asp

For more information about working with local user accounts:
http://msdn.microsoft.com/library/en-us/adsi/adsi/users.asp


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


0 new messages