Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Import all the users in specific OU To Distribution list

Posted on 2016-07-24
6
Medium Priority
?
67 Views
Last Modified: 2016-08-22
Hi Guy,


I wonder if there is any way I can do the following

I have an OU called test which have about 1500 users I need to add them to DL every time someone created a New users in this Test OU .

Note : this OU has a Sub Tree OU’s as well

Thank you in advance and appreciate your Quick response
0
Comment
Question by:Rabihhaj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 9

Accepted Solution

by:
Antzs earned 1000 total points (awarded by participants)
ID: 41726892
I would assume you are using Exchange.  In Exchange you can use Dynamic Distribution Group(DDG) to achieve this.  When creating the DDG, you will be able to set the rule to include users from specific OUs.

So the next time anyone add a user in the OU it will be included into the DDG.
0
 
LVL 43

Assisted Solution

by:Adam Brown
Adam Brown earned 500 total points (awarded by participants)
ID: 41726991
Dynamic Distribution Group is the way to go on this one, but be aware that with 1500 users there will probably be a noticeable delay in mail delivery when sending to the group, since DDGs have to determine membership at time of delivery for each message sent.

If that delay is not acceptable, it's possible to add all of the users in an OU to a specific group by using the -organizationalunit switch of the get-mailbox cmdlet, then piping that to add-distributiongroupmember, like this:

get-mailbox -organizationalunit <OU Name> | add-distributiongroupmember <Distribution group name

Open in new window

1
 
LVL 9

Expert Comment

by:Antzs
ID: 41727005
The delay would probably be minimum depending on the Exchange performance.  I have a DDG which adds about 1000 users and I dont see any delay.

But if using the -organizationalunit switch, the Exchange PowerShell Script would probably need to be run on a schedule so that new users created in the OU will continue to be added into the group.
1
Q2 2017 - Latest Malware & Internet Attacks

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out our latest Quarterly Internet Security Report!

 
LVL 9

Assisted Solution

by:dipersp
dipersp earned 500 total points (awarded by participants)
ID: 41727509
I'm also assuming Exchange.

Anything we can automate when it comes to "every user" or every user in an OU, use Exchange CmdletExtensionAgent (If Exchange 2010+).  This is basically a powershell script that runs every time a user action is performed, such as a new mailbox.  

There is a file named ScriptingAgentConfig.xml.sample that is located under C:\Program Files\Microsoft\Exchange Server\V14\Bin\CmdletExtensionAgents.  Remove the .SAMPLE extension and then edit the file to do what you want.  Lots of examples online.  Here's one we use for adding every user to a retention policy when we create a mailbox -

<?xml version="1.0" encoding="utf-8" ?>
<Configuration version="1.0">
    <Feature Name="MailboxProvisioning" Cmdlets="new-mailbox,enable-mailbox">
 
         <ApiCall Name="OnComplete">
              if($succeeded) {
                Set-Mailbox $provisioningHandler.UserSpecifiedParameters["Alias"] -RetentionPolicy "_EnerTech Default Retention Policy"
               }
         </ApiCall>
     </Feature>
</Configuration>

Open in new window


Once you have the file doing what you want (You'll want to add in an IF to check the OU), then you enable the agent by entering the following in PS -

Enable-CmdletExtensionAgent "Scripting Agent"

Also if you have more than one Exchange box, make sure to copy the XML to all boxes.
1
 

Author Comment

by:Rabihhaj
ID: 41733812
all comments are helpful
0
 
LVL 43

Expert Comment

by:Adam Brown
ID: 41757588
Asker suggested that all the comments were helpful, but did not grade.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question