Re: Add domain group to local group?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Steve Thompson (stevethompson_at_nomail.please)
Date: 11/10/04


Date: Wed, 10 Nov 2004 10:02:16 -0500


"Steve Thompson" <stevethompson@nomail.please> wrote in message
news:u$qasNzxEHA.2984@TK2MSFTNGP10.phx.gbl...
> I'm looking for a code snippet to add a domain global group to a local
group
> (such as Administrators) on a client.

Found the answer after posting this question, code from Richard Mueller
(thanks Richard).

' Specify AdsPath of domain group to be added to
' local Administrators group.
' strDomainGroup = "WinNT://MyDomain/ComputerAdmins,group"

' Bind to domain group.
Set objDomainGroup = GetObject(strDomainGroup)

' Retrieve local computer NetBIOS name.
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName

' Bind to local Administrators group.
Set objLocalGroup = GetObject("WinNT://" & strComputer _
  & "/Administrators,group")

' Check if domain group already a member.
If Not objLocalGroup.IsMember(objDomainGroup.AdsPath) Then
  ' Add domain group to local group.
  objLocalGroup.Add(objDomainGroup.AdsPath)
End If



Relevant Pages

  • Re: "add domain group to local group" stopped working
    ... ' Specify AdsPath of domain group to be added to ... Set objDomainGroup = GetObject ... ' Bind to local Administrators group. ...
    (microsoft.public.scripting.vbscript)
  • Re: Whos got local admin group script AGAINST OU
    ... object and enumerate child objects within. ... you would modify to bind to the OU object. ... computer bind to the local Administrators group and enumerate the members. ... ' Enumerate direct members of the group. ...
    (microsoft.public.windows.server.scripting)
  • Re: Scripting questions
    ... list all users in local administrators group on remote computer ... For example, JUser could be a member of domain group "Sales", which is a member of domain group "West", which is a member of the local Administrators group on computer "WST101". ... Bind to the local administrators group on the remote computer and use the Remove method of the group object. ...
    (microsoft.public.windows.server.scripting)