Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 83
  • Last Modified:

Import all the users in specific OU To Distribution list

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
Rabihhaj
Asked:
Rabihhaj
3 Solutions
 
AntzsInfrastructure ServicesCommented:
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
 
Adam BrownSr Solutions ArchitectCommented:
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
 
AntzsInfrastructure ServicesCommented:
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
Building an Effective Phishing Protection Program

Join Director of Product Management Todd OBoyle on April 26th as he covers the key elements of a phishing protection program. Whether you’re an old hat at phishing education or considering starting a program -- we'll discuss critical components that should be in any program.

 
diperspCommented:
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
 
RabihhajAuthor Commented:
all comments are helpful
0
 
Adam BrownSr Solutions ArchitectCommented:
Asker suggested that all the comments were helpful, but did not grade.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Building an Effective Phishing Protection Program

Join Director of Product Management Todd OBoyle on April 26th as he covers the key elements of a phishing protection program. Whether you’re an old hat at phishing education or considering starting a program -- we'll discuss critical components that should be in any program.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now