Improve company productivity with a Business Account.Sign Up

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

Exchange Power Shell to add users to a Distribtuion Group

I am looking for a PowerShell script that will allow us to add users in bulk to a Distribution Group. We were able do the DG addistion in bulk but now we need to add the users.
0
jwhitepnv
Asked:
jwhitepnv
  • 2
1 Solution
 
crimmelCommented:
I highly recommend doing this using Quest's Active Roles Management Shell for AD.  You can download this from here:

http://www.quest.com/powershell/activeroles-server.aspx

The commands in this management shell are infinitely easier than the ones required when using the basic Powershell from Microsoft.

Anyway, once you get these installed, create a csv file called "userlist.csv" with a list of all of your users (I would recommend using the samaccountname).  Then copy and paste the code below into a file titled "addgroupmembers.ps1".  Run the script to add members to a group by running ".\addgroupmembers.ps1 userlist.csv" from within the Quest Active Roles Mgmt Shell.

$users = get-content List of users
 
Foreach($user in $users)
	{
	Add-qadgroupmember Identity CN=GroupName,OU=OUName,DC=DCName Member $user
	} 

Open in new window

0
 
crimmelCommented:
For some reason, the quote marks in the original code snippet above were dropped and may cause problems for you.  Use the following as I have removed the quotes and run it by typing simply ".\addgroupmemers.ps1".  Be sure to place the csv file in the correct location or point the get-content command to the correct location:

$users = get-content c:\scripts\userlist.csv

Foreach($user in $users)
      {
      Add-qadgroupmember Identity CN=GroupName,OU=OUName,DC=DCName Member $user
      }
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

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

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