Solved

Import all the users in specific OU To Distribution list

Posted on 2016-07-24
6
37 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
6 Comments
 
LVL 5

Accepted Solution

by:
Antzs earned 250 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 38

Assisted Solution

by:Adam Brown
Adam Brown earned 125 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 5

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
 
LVL 9

Assisted Solution

by:dipersp
dipersp earned 125 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 38

Expert Comment

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

Join & Write a Comment

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This article will help you understand what HashTables are and how to use them in PowerShell.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now