none
How to add multiple users (email address) to an Exchange 2010 distribution group via Powershell V1.0 RRS feed

  • Question

  • Hello Everyone,

    So I need to add 75 email addresses to a Exchange 2010 distribution, but I seem to be stumped on how to do so. After doing some research, I found that the best approach was to import them from a file through a script. The name of the file is user.txt, the DG is called SuiteWorld 2015 Cell Group, and the script is called Add.ps1. Below is the content of the script:

    Get-Content c:\users.txt | ForEach-Object {
      Add-DistributionGroupMember -Identity SuiteWorld 2015 Cell Group -Member $_
    }

    How would I run the Add.ps1 script? This is my first experience with Powershell, so please bare with me.

    Thanks for the help.


    Monday, December 8, 2014 5:35 PM

Answers

  • A question first of all. Do the 75 users you want to add to the distribution group have mailboxes or mail contacts? I ask because email addresses outside of your exchange need to have email contacts created before they can be added to a distribution list. If the users/contacts already exist in your exchange, the following procedure will work: 1. Create a CSV with one column with the column titled "user" and save it on one of your Exchange servers as users.csv 2. From the Exchange server where you saved the file, run the Exchange Management Shell from the start menu 3. Type Import-CSV c:\folder\users.csv | foreach {Add-DistributionGroupMember -Identity SuiteWorld 2015 Cell Group -Member $_.user} If you want to execute a .ps1 script file, open the management shell and navigate to where the script file is, then type .\Scriptname.ps1 This will execute the script. Hope that helps. NOTE: contrary to what JSV says, add-distributiongroupmember does accept SMTP address for the member attribute: http://technet.microsoft.com/en-us/library/bb124340(v=exchg.141).aspx

    CRM Advisor


    • Edited by Peter Moys Tuesday, December 9, 2014 10:49 PM Correcting typo
    • Proposed as answer by Peter Moys Wednesday, December 10, 2014 6:23 AM
    • Marked as answer by AnnaWYModerator Sunday, December 21, 2014 8:58 AM
    Monday, December 8, 2014 7:52 PM

All replies

  • Hello Nate,

    1. In the EAC, navigate to "Recipients" > "Mailboxes"

    2. Click "New" > "User mailbox"

    3. On the "New user mailbox" page, in the "Alias" box, type the user’s alias, which specifies the email alias for the user. The user’s alias is the portion of the email address on the left side of the at (@) symbol. It must be unique in the forest.

    http://technet.microsoft.com/en-us/library/jj991919(v=exchg.150).aspx

    Hope this helps! 


    Monday, December 8, 2014 5:51 PM
  • Exchange 2010 requires at least Powershell V2.

    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    Monday, December 8, 2014 6:02 PM
  • Hello Everyone,

    So I need to add 75 email addresses to a Exchange 2010 distribution, but I seem to be stumped on how to do so. After doing some research, I found that the best approach was to import them from a file through a script. The name of the file is user.txt, the DG is called SuiteWorld 2015 Cell Group, and the script is called Add.ps1. Below is the content of the script:

    Get-Content c:\users.txt | ForEach-Object {
      Add-DistributionGroupMember -Identity SuiteWorld 2015 Cell Group -Member $_
    }

    How would I run the Add.ps1 script? This is my first experience with Powershell, so please bare with me.

    Thanks for the help.


    I highly recommend learning PowerShell or you will beat themercy of those who post bad answers to simple quesiotns.

    You need to understand how to use strings and how to execute scripts with PowerShell.

    Start here: http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx

    http://technet.microsoft.com/en-us/library/aa995970(v=exchg.141).aspx

    Distribution grouops take user objects andnot email addresses.  If you want a distribution list then you would use the contacts forlde to add a distribution list.  This can be easily done in Outlook.


    ¯\_(ツ)_/¯

    Monday, December 8, 2014 6:04 PM
    Moderator
  • Hi jrv,

    I actually have seen the links you provided before. I'm just looking for a quick solution to the issue that needs to be solved ASAP. What is the contacts forlde?

    Monday, December 8, 2014 6:22 PM
  • Hi jrv,

    I actually have seen the links you provided before. I'm just looking for a quick solution to the issue that needs to be solved ASAP. What is the contacts forlde?


    Do you use Outlook?  DO you use OWA (outlook on O365)?  what are you trying to accomplish. It is unclear.

    ¯\_(ツ)_/¯

    Monday, December 8, 2014 6:29 PM
    Moderator
  • A question first of all. Do the 75 users you want to add to the distribution group have mailboxes or mail contacts? I ask because email addresses outside of your exchange need to have email contacts created before they can be added to a distribution list. If the users/contacts already exist in your exchange, the following procedure will work: 1. Create a CSV with one column with the column titled "user" and save it on one of your Exchange servers as users.csv 2. From the Exchange server where you saved the file, run the Exchange Management Shell from the start menu 3. Type Import-CSV c:\folder\users.csv | foreach {Add-DistributionGroupMember -Identity SuiteWorld 2015 Cell Group -Member $_.user} If you want to execute a .ps1 script file, open the management shell and navigate to where the script file is, then type .\Scriptname.ps1 This will execute the script. Hope that helps. NOTE: contrary to what JSV says, add-distributiongroupmember does accept SMTP address for the member attribute: http://technet.microsoft.com/en-us/library/bb124340(v=exchg.141).aspx

    CRM Advisor


    • Edited by Peter Moys Tuesday, December 9, 2014 10:49 PM Correcting typo
    • Proposed as answer by Peter Moys Wednesday, December 10, 2014 6:23 AM
    • Marked as answer by AnnaWYModerator Sunday, December 21, 2014 8:58 AM
    Monday, December 8, 2014 7:52 PM
  • You cannot add a group ,member by member name.  You need to use a user identity or a user object.  'Name" is not unique.  'SamAccountName'  and 'Alias' are unique but only within a domain.  NTAccount is unique wither as a UPN or as a Pre-W2K name.

    Again - if you just want a mail distribution list use either Outlook or OWA.  In the Gallery are examples of how to do both.

    If this is an internal distribution "group"  then  find the members by unique ID whichever you have.  If you have emails then you can use those to search for user and contact objects.  You can also use the list to create contacts but not users.


    ¯\_(ツ)_/¯

    Monday, December 8, 2014 8:33 PM
    Moderator
  • You cannot add a group ,member by member name.  You need to use a user identity or a user object.  'Name" is not unique.  'SamAccountName'  and 'Alias' are unique but only within a domain.  NTAccount is unique wither as a UPN or as a Pre-W2K name.

    Again - if you just want a mail distribution list use either Outlook or OWA.  In the Gallery are examples of how to do both.

    If this is an internal distribution "group"  then  find the members by unique ID whichever you have.  If you have emails then you can use those to search for user and contact objects.  You can also use the list to create contacts but not users.


    ¯\_(ツ)_/¯


    So what are you saying?

    CRM Advisor

    Monday, December 8, 2014 11:20 PM
  • You can't just simple use the CN.  It is not unique.  The DN, UPN and NTAccoutn are all unique.  CN or "Name" are only unique within a container.

    Look at the rules for "Identity".  They do not include Name or CN.


    ¯\_(ツ)_/¯

    Monday, December 8, 2014 11:52 PM
    Moderator
  • The user is using email address which is unique, so there is no problem.

    CRM Advisor

    Tuesday, December 9, 2014 7:27 AM
  • The user is using email address which is unique, so there is no problem.

    CRM Advisor

    Email address is not an identity and c annot be used as an identity. Have you actually ever tried any of these things?

    Proof:

    This works:

    get-aduser -filter 'mail -eq "jsmith@mydomian.com"'

    This doesn't:

    get-aduser -identity "jsmith@mydomian.com"'

    A mail address is not an identity.

    You can filter for a user by mail address then add the retrived user object to a list.  THat is all.


    ¯\_(ツ)_/¯

    Tuesday, December 9, 2014 7:54 AM
    Moderator
  • You are wrong in this case.  SMTP address is valid for identity: http://technet.microsoft.com/en-us/library/bb124340(v=exchg.141).aspx

    "Have you actually ever tried any of these things?"


    CRM Advisor

    Tuesday, December 9, 2014 8:13 AM
  • Ok - yes - if we are only referring to Exchange Shell.  I was referring to AD groups.  I forgot we were looking at Exchange Shell.

    Yes we can use emaila addresses but only if they are already in AD.  As noted only objects in AD that are mail enable are legtimate in Exchaneg Dist groups.

    Sorry for the confusion.


    ¯\_(ツ)_/¯

    Tuesday, December 9, 2014 8:29 AM
    Moderator