?
Solved

Exchange Power Shell to add users to a Distribtuion Group

Posted on 2009-04-05
2
Medium Priority
?
512 Views
Last Modified: 2012-06-21
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
Comment
Question by:jwhitepnv
[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
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
crimmel earned 2000 total points
ID: 24073816
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
 
LVL 4

Expert Comment

by:crimmel
ID: 24073858
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

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
On September 18, Experts Exchange launched the first installment of the Help Bell, a new feature for Premium Members, Team Accounts, and Qualified Experts. The Help Bell will serve as an additional tool to help teams increase question visibility.
This video discusses moving either the default database or any database to a new volume.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

718 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