Is there any way to use a VBScript to add Active Directory users or
groups to the local administrators group?

Re: VBScript to AD users or groups to the local administrator group by Torgeir

Torgeir
Thu Sep 09 15:59:23 CDT 2004

Michael wrote:
> Is there any way to use a VBScript to add Active Directory users or
> groups to the local administrators group?
Hi

You can use ADSI's WinNT provider.

Here is an example on how to add a domain user to the local
administrator group (VBScript):

http://groups.google.com/groups?selm=e9QinYwbEHA.2908%40TK2MSFTNGP10.phx.gbl


--
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/default.mspx

Re: VBScript to AD users or groups to the local administrator group by Jeff

Jeff
Thu Sep 09 16:07:59 CDT 2004

I use the following in a login Script to accomplish what you are wanting.

Dim strUser, StrGroup, StrComputer, objNetwork, StrDomain
Set objNetwork = CreateObject("Wscript.Network")
'Gets local computer name
StrComputer =objNetwork.ComputerName
'Put the name of the user or group here
StrDomainGroup = "GroupName"
'Put your Netbios domain name here
StrDomain= "DomainName"
'Put the local group name you want to add the user/group to.
StrLocalGroup = "Administrators"

Call AddToLocalGroup(strComputer, strLocalGroup, strDomainGroup, strDomain)

Sub AddToLocalGroup(strComputer, strLocalGroup, strDomainGroup, strDomain)
Dim objLocalGroup, objDomainGroup
Set objLocalGroup = GetObject("WinNT://" & strComputer & "/" &
strLocalGroup & ",Group")
Set objDomainGroup = Getobject("WinNT://" & strDomain & "/" &
strDomainGroup & ",Group")
If Not objLocalGroup.IsMember(objDomainGroup.AdsPath) Then
objLocalGroup.Add(objDomainGroup.AdsPath)
End If

End Sub



Jeff


"Michael" <mjwhite@nbnet.nb.ca> wrote in message
news:ce72167f.0409091036.6abc6a96@posting.google.com...
> Is there any way to use a VBScript to add Active Directory users or
> groups to the local administrators group?



Re: VBScript to AD users or groups to the local administrator group by mjwhite

mjwhite
Thu Sep 09 21:38:50 CDT 2004

Thanks Jeff -- Just what I was looking for!