Re: Copy users from one group to a new group
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 14 Mar 2008 09:01:56 -0500
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
--
.
- Prev by Date: Re: DNS 4521 - old zones
- Next by Date: Re: Multiple DCs but can't login if FSMO role holder is offline
- Previous by thread: Re: DNS 4521 - old zones
- Next by thread: Re: Multiple DCs but can't login if FSMO role holder is offline
- Index(es):
Relevant Pages
|