Search WWW Search

Tuesday, August 07, 2007

Active Directory: Copy Distribution List Members to Another Distribution List

Summary: In this example, we will copy all members from one Distribution Group to another Distribution Group.

Copy the contents below and save as copymembers.vbs to C: drive


Set objOU = GetObject("LDAP://OU=Security Groups, dc=company, dc=com")
Set objOldGroup = GetObject("LDAP://CN=mysourcegroup, ou=security groups, dc=company, dc=com")
Set objNewGroup = GetObject("LDAP://CN=mytargetgroup, ou=security groups, dc=company, dc=com")

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

Open Command prompt:

C:\>cscript copymembers.vbs

The script will copy all members in the "mysourcegroup" Distribution List to your "mytargetgroup" Distribution List.

Note: Some organizations like to use # in front of their Distribution List names so they appear together in the GAL. Because this is a special character it will need to be in double quotes to treat # as a literal.


James Chong (MVP)MCSE M+, S+, MCTS, Security+

How useful was this article? Want to see a tip not listed? Please leave a comment.


Blogger Support said...


This article is good and informative.

yours truly,

1:09 AM  
Anonymous Anonymous said...

I love you!!

You saved me hours and hours...
Keep up the good work, I have your blog in my Bookmarks and come back to it constantly

8:52 AM  
Blogger madhavan said...

Really useful info, it worked and saved lot of time for me.

Thanks a lot.


4:16 AM  
Anonymous Anonymous said...

Thanks a bunch! Exactly the quick script our organization was seeking.

1:34 PM  
Anonymous Anonymous said...

Thanks a bunch! Exactly the quick script our organization was seeking.

1:35 PM  
Blogger Robert said...

Thank you for posting this!!!!

6:11 AM  
Blogger David said...

I'm not able to get the script to work. Not enough information. Need an exampl.

8:17 AM  
Blogger Mick Tripps said...

I changed "mysourcegroup" and "mytargetgroup" to the correct group names, but the script fails with this error. What did I miss? Does the script have to be run from the Exchange server? Do any other values in the example have to be changed? Thank you.


C:\>cscript copy_group.vbs
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

C:\copy_group.vbs(3, 1) (null): A referral was returned from the server.

10:40 AM  
Anonymous Martijn said...

This article has saved me alot of time. Thanks!

2:40 AM  
Anonymous KeithL said...

I tried the scrip and it runs without error, but does not populate the target group. My groups are universal groups, I am wondering if that matters?

8:02 AM  
Anonymous Anonymous said...

I think 2moons dil changes my life. Because of 2moons gold, I meet a lot of friends. Besides, my friends usually give me some 2moon dil. I usually buy 2moons dil through Internet and advice from my friends, so I gain a lot of cheap 2moons gold and harvest in life.

9Dragons is a very good game. Through buying 9Dragons gold, I find fun in it. I am so glad that I can earn a lot of 9 Dragons gold. 9Dragons cater to the taste of young people. With cheap 9Dragons gold, you can get everything you want in this game. So I like to buy 9 Dragons gold. For me 9Dragons money is not just a simple thing.

7:44 PM  
Anonymous cheap rappelz rupees said...

I like play online game, I also buy ragnarok online zeny and ro zeny, the ragnarok zeny is very cheap, and use the iro zeny can buy many things, I like cheap zeny, thanks, it is very good.

I like play online game, I also buy rupees and rappelz rupees, the rappelz gold is very cheap, and use the rappelz money can buy many things, I like cheap rappelz rupees, thanks, it is very good.

6:08 PM  
Anonymous Anonymous said...

Thanks.. It works amazing.. awesome

2:54 PM  
Anonymous Anonymous said...

Thanks for the script, managed to get it working after lots of trial & error.

Seems the script is very fussy on upper / lower case characters. Also had to create the new distribution list and put it into the correct OU before it would work, and had to make sure that both old and new DL's were global not universal.

Hope that helps somebody.

7:44 AM  
Anonymous Anonymous said...

Thank you so much - you saved my day! :-)

May it is helpful to use add. the MS-Tool ldp (Server support tools) it helps you figure out the right LDAP path information, I had trouble with them first ;-).

Clear, straight forward help as needed. - Thank you!


9:00 AM  
Blogger 123 123 said...

Interesting article you got here. I'd like to read a bit more about this matter. Thnx for posting that info.
Sexy Lady
Blonde escort

6:23 AM  
Anonymous Anonymous said...






Thanks from Argentina
C. Castagnola!!!

1:47 PM  
Anonymous Anonymous said...

The Hogan scarpe
brand is distinctive for high quality. Hogan scarpe donna
are the highest expression of a new luxury lifestyle. hogan donna
is meant for someone who cherishes the type of luxury associated. Apparently Ben had extra spikes put in his Hogan scarpe uomo
for extra grip.

6:20 PM  
Anonymous Tech solution said...

Thanks for the solution, it works fine

10:53 PM  
Anonymous Anonymous said...

working brilliant
thank you

9:29 AM  

Post a Comment

<< Home

xml:lang="en" lang="en"> MS Exchange Tips: Active Directory: Copy Distribution List Members to Another Distribution List