Re: Copy users from one group to a new group



UnderCoverGuy wrote:

Good evening. I am working with a number of groups in AD, each with
hundreds
of members. I need to copy members from a group to different global
security
group.

Also, some of these groups are users and some are computer objects (group
policy processing stuff).

Does anyone have an easy method to accomplish this task (vbScript,
command-line, etc.)?


A VBScript solution:
============
' Bind to "source" group object, using full Distinguished Name.
Set objSource = GetObject("LDAP://cn=Sales,ou=West,dc=MyDomain,dc=com";)

' Bind to "target" group object, using full Distinguished Name.
Set objTarget = GetObject("LDAP://cn=Sales,ou=East,dc=MyDomain,dc=com";)

' Enumerate direct members of source group.
For Each strMemberDN In objSource.member
' Check if this member already in target group.
If (objTarget.IsMember("LDAP://"; & strMemberDN) = False) Then
' Add the member to the target group.
objTarget.Add("LDAP://"; & strMemberDN)
End If
Next

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Need limited domain admin rights user account.
    ... I believe you are looking at the permission on the group object ... This is different from the members in the group, ... Domain Admins will have full control over the group while ...
    (microsoft.public.windows.server.security)
  • Re: User objects cannot be created in the specified container
    ... CN is a group object. ... of members that are allowed to access my application. ... If I point the LDAP connection to OU12, I am not getting the above ... If we put a test user directly under OU12 every thing works. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: HOW TO EXPORT FROM AD 2003 DISTRIBUTION LIST TO EXCEL
    ... The command line tools dsquery and dsget can be used to retrieve the ... ' Bind to group object, using Distinguished Name of the group. ... ' Use Members method to enumerate members of the group. ... a VBScript program can also write to an Excel Spreadsheet. ...
    (microsoft.public.windows.server.active_directory)
  • How to get users of a group
    ... I need to get all users that are members of a group. ... Problem is, looking at the properties of a group object, i can not find ... cn: Domain Users ... sAMAccountName: Domain Users ...
    (microsoft.public.windows.server.active_directory)