Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Active Directory
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: ,

Sponsored Links



copying users form one group to a new group

Active Directory


Reply
 
Thread Tools Search this Thread
  #1  
Old 28-10-2009
Johan deheugden
 
Posts: n/a
copying users form one group to a new group

Is it possible to copy(not move) users from one group to a different group
through a script? am creating some new sites in AD and i dont want to do the
copying by hand. I did find the following script(heyscriptingguy):
Const ADS_GROUP_TYPE_GLOBAL_GROUP = &H2

Set objOU = GetObject("LDAP://OU=Finance, dc=fabrikam, dc=com")
Set objOldGroup = GetObject("LDAP://CN=Finance Managers, ou=Finance,
dc=fabrikam, dc=com")

Set objNewGroup = objOU.Create("Group", "Finance Department")
objNewGroup.sAMAccountName = "financedept"
objNewGroup.groupType = ADS_GROUP_TYPE_GLOBAL_GROUP
objNewGroup.Set Info

For Each objUser in objOldGroup.Member
objNewGroup.Add "LDAP://" & objUser
Next

but that script is moving from 1 group to a group thats also being created.
My destinationgroups already exist
Reply With Quote
  #2  
Old 28-10-2009
Meinolf Weber [MVP-DS]
 
Posts: n/a
Re: copying users form one group to a new group

Hello Johan,

Check out Marcins answer:
----------------------------------------------------------------------
Is this what you are looking for?

Set oGroup1 =
GetObject("LDAP://cn=Group1,ou=Groups,dc=change-my-name,dc=local")
Set oGroup2 =
GetObject("LDAP://cn=Group2,ou=Groups,dc=change-my-name,dc=local")

For Each oUser in oGroup1.Members
oGroup2.Add(oUser.ADsPath)
Next

hth
Marcin
----------------------------------------------------------------------
From:
How to Export users from the Domain Users group into another Sec G

Best regards

Meinolf Weber
Disclaimer: This posting is provided "AS IS" with no warranties, and confers
no rights.
** Please do NOT email, only reply to Newsgroups
** HELP us help YOU!!! http://www.blakjak.demon.co.uk/mul_crss.htm


> Is it possible to copy(not move) users from one group to a different
> group
> through a script? am creating some new sites in AD and i dont want to
> do the
> copying by hand. I did find the following script(heyscriptingguy):
> Const ADS_GROUP_TYPE_GLOBAL_GROUP = &H2
> Set objOU = GetObject("LDAP://OU=Finance, dc=fabrikam, dc=com")
> Set objOldGroup = GetObject("LDAP://CN=Finance Managers, ou=Finance,
> dc=fabrikam, dc=com")
> Set objNewGroup = objOU.Create("Group", "Finance Department")
> objNewGroup.sAMAccountName = "financedept" objNewGroup.groupType =
> ADS_GROUP_TYPE_GLOBAL_GROUP objNewGroup.Set Info
>
> For Each objUser in objOldGroup.Member
> objNewGroup.Add "LDAP://" & objUser
> Next
> but that script is moving from 1 group to a group thats also being
> created. My destinationgroups already exist
>



Reply With Quote
  #3  
Old 28-10-2009
Johan deheugden
 
Posts: n/a
Re: copying users form one group to a new group

indeed. thats it. didnt find it.
tha

"Meinolf Weber [MVP-DS]" wrote:

> Hello Johan,
> nks for the reply
> Check out Marcins answer:
> ----------------------------------------------------------------------
> Is this what you are looking for?
>
> Set oGroup1 =
> GetObject("LDAP://cn=Group1,ou=Groups,dc=change-my-name,dc=local")
> Set oGroup2 =
> GetObject("LDAP://cn=Group2,ou=Groups,dc=change-my-name,dc=local")
>
> For Each oUser in oGroup1.Members
> oGroup2.Add(oUser.ADsPath)
> Next
>
> hth
> Marcin
> ----------------------------------------------------------------------
> From:
> How to Export users from the Domain Users group into another Sec G
>
> Best regards
>
> Meinolf Weber
> Disclaimer: This posting is provided "AS IS" with no warranties, and confers
> no rights.
> ** Please do NOT email, only reply to Newsgroups
> ** HELP us help YOU!!! http://www.blakjak.demon.co.uk/mul_crss.htm
>
>
> > Is it possible to copy(not move) users from one group to a different
> > group
> > through a script? am creating some new sites in AD and i dont want to
> > do the
> > copying by hand. I did find the following script(heyscriptingguy):
> > Const ADS_GROUP_TYPE_GLOBAL_GROUP = &H2
> > Set objOU = GetObject("LDAP://OU=Finance, dc=fabrikam, dc=com")
> > Set objOldGroup = GetObject("LDAP://CN=Finance Managers, ou=Finance,
> > dc=fabrikam, dc=com")
> > Set objNewGroup = objOU.Create("Group", "Finance Department")
> > objNewGroup.sAMAccountName = "financedept" objNewGroup.groupType =
> > ADS_GROUP_TYPE_GLOBAL_GROUP objNewGroup.Set Info
> >
> > For Each objUser in objOldGroup.Member
> > objNewGroup.Add "LDAP://" & objUser
> > Next
> > but that script is moving from 1 group to a group thats also being
> > created. My destinationgroups already exist
> >

>
>
> .
>

Reply With Quote
  #4  
Old 28-10-2009
Johan deheugden
 
Posts: n/a
RE: copying users form one group to a new group

thats it. thanks for the reply, youre saving me hours of work .
Reply With Quote
  #5  
Old 28-10-2009
Meinolf Weber [MVP-DS]
 
Posts: n/a
RE: copying users form one group to a new group

Hello Johan,

You're welcome.

Best regards

Meinolf Weber
Disclaimer: This posting is provided "AS IS" with no warranties, and confers
no rights.
** Please do NOT email, only reply to Newsgroups
** HELP us help YOU!!! http://www.blakjak.demon.co.uk/mul_crss.htm


> thats it. thanks for the reply, youre saving me hours of work .
>



Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Active Directory


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "copying users form one group to a new group"
Thread Thread Starter Forum Replies Last Post
How to Export users from the Domain Users group into another Sec G CK Active Directory 6 30-11-2011 11:54 PM
How would I assign a group policy only to certain users in an OU? chinwan Active Directory 4 18-01-2010 12:06 AM
Way for end users to see group membership? £Jim Active Directory 2 07-03-2009 02:59 AM
ADMT 3.0 Users Migration: Fix Users' Group Memberships stopped working Jason Windows Server Help 11 05-12-2008 01:14 PM
Add users to Group via Script - [WP] WILDPACKET Active Directory 9 30-01-2008 12:30 AM


All times are GMT +5.5. The time now is 12:06 PM.