PC Review Forums Newsgroups Windows XP Windows XP WMI add user

Reply

add user

 
Thread Tools Rate Thread
Old 19-07-2004, 05:36 AM   #1
=?Utf-8?B?SEI=?=
Guest
 
Posts: n/a
Default add user


Please give us help, we need use script add some domain user into many computer's local administrators group.
  Reply With Quote
Old 19-07-2004, 07:01 PM   #2
Torgeir Bakken \(MVP\)
Guest
 
Posts: n/a
Default Re: add user

HB wrote:

> Please give us help, we need use script add some domain user into
> many computer's local administrators group.

Hi

If Active Directory domain:

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

Here is a vbscript for you as a starting point:

'--------------------8<----------------------

Set oWshNet = CreateObject("WScript.Network")

sUser = "fill in some some user name here"

sNetBIOSDomain = oWshNet.UserDomain
sComputer = oWshNet.ComputerName

Set oGroup = GetObject("WinNT://" & sComputer & "/Administrators,group")
Set oUser = GetObject("WinNT://" & sNetBIOSDomain & "/" & sUser & ",user")

' suppress errors in case the user is already a member
On Error Resume Next
oGroup.Add(oUser.ADsPath)
On Error Goto 0
'--------------------8<----------------------


It will try to add the user name in the variable "sUser"
to the "Administrators" group every time the computer boots
up. If the user already exists, the error is suppressed.

If the computers are in another domain than the user you
want to add, you will need to hard code the domain name
the user belongs to in the variable "sNetBIOSDomain".


WSH 5.6 documentation (local help file) can be downloaded from here
if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.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/sc...er/default.mspx
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off