locked
Adding bulk secondary smtp addresses to Distribution Groups with .csv in Exchange 2016 RRS feed

  • Question

  • Adding smtp addresses to Distribution Groups with .csv in Exchange 2016

    Tuesday, October 29, 2019 2:34 PM

Answers

  • Hello,

    Import-CSV C:\scripts\groups.csv | foreach {
    Set-DistributionGroup -identity $_.identitys -EmailAddresses @{Add=$_.EmailAdresses}
    }

    your CSV must have a ID name identitys (can be primary smtp adresses)

    and emailadresses value for the second smtp adresses.

    Olivier.


    Tuesday, October 29, 2019 3:05 PM
  • Corrected, quote was bad

    your CSV must be like that :

    identitys,EmailAdresses
    it@consto.com,support@contoso.com
    it@consto.com,support@fabrikam.com

    Tuesday, October 29, 2019 6:35 PM
  • did you use it with exchange powershell ?  i just tested it, and worked on exchange 2013

    could you change

    Import-CSV C:\scripts\groups.csv | foreach {
    Set-DistributionGroup -identity $_.identitys -EmailAddresses @{Add=$_.EmailAdresses}
    }

    by

    Import-CSV C:\scripts\groups.csv | foreach {
    write-host $_.identitys
    wirte-host $_.EmailAdresses
     }
    }

    and see if these values are good ?

    Olivier

    Tuesday, October 29, 2019 8:08 PM
  • you csv must be :

    identitys,EmailAdresses
    it@consto.com,support@contoso.com
    it@consto.com,support@fabrikam.com

    made it with notepad; no space.

    Tuesday, October 29, 2019 8:50 PM

All replies

  • Please carefully review the following links to set your expectation for posting in technical forums.


    \_(ツ)_/

    Tuesday, October 29, 2019 2:39 PM
  • Hello,

    Import-CSV C:\scripts\groups.csv | foreach {
    Set-DistributionGroup -identity $_.identitys -EmailAddresses @{Add=$_.EmailAdresses}
    }

    your CSV must have a ID name identitys (can be primary smtp adresses)

    and emailadresses value for the second smtp adresses.

    Olivier.


    Tuesday, October 29, 2019 3:05 PM
  • And please remember that the e-mail addresses you're adding require a "type", and that the "type" must be in lower-case (because they're "secondary" addresses). For example:

    smtp:dl1@domain.com


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Tuesday, October 29, 2019 3:14 PM
  • if i read correctly, this is not needed with this method:

    https://docs.microsoft.com/en-us/Exchange/recipients/user-mailboxes/email-addresses?view=exchserver-2019

    as you add, its secondary.


    Tuesday, October 29, 2019 3:20 PM
  • Ahhh . . . yes, you're right. It didn't used to be that way (before the advent of the ability to use splatting). We used to have to modify the EMailAddresses property as an entire set.

    Chalk that up to my being an old fogey. :-)


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Tuesday, October 29, 2019 3:32 PM
  • getting error message

    Cannot bind argument to parameter 'Identity' because it is null.

       + CategoryInfo              : InvalidData: (:) [Set-DistributionGroup], ParameterBindingValidationException

        + FullyQualifiedErrorID  : ParameterArgumentValidationErrorNullNotAllowed,Set-DistributionGroup

        + PSComputerName      : **********.local 

    

    Tuesday, October 29, 2019 6:10 PM
  • Post the code you're using. And the first couple of lines from the CSV file.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Tuesday, October 29, 2019 6:24 PM
  • Corrected, quote was bad

    your CSV must be like that :

    identitys,EmailAdresses
    it@consto.com,support@contoso.com
    it@consto.com,support@fabrikam.com

    Tuesday, October 29, 2019 6:35 PM
  • Still gettting error with this script and .csv
    Tuesday, October 29, 2019 7:58 PM
  • did you use it with exchange powershell ?  i just tested it, and worked on exchange 2013

    could you change

    Import-CSV C:\scripts\groups.csv | foreach {
    Set-DistributionGroup -identity $_.identitys -EmailAddresses @{Add=$_.EmailAdresses}
    }

    by

    Import-CSV C:\scripts\groups.csv | foreach {
    write-host $_.identitys
    wirte-host $_.EmailAdresses
     }
    }

    and see if these values are good ?

    Olivier

    Tuesday, October 29, 2019 8:08 PM
  • Cannot process argument transformation on parameter 'EmailAddresses'. Cannot convert value

    "System.Collections.Hashtable" to type "Microsoft.Exchange.Data.ProxyAddressCollection". Error: "The address '$_.EmailAdresses' is invalid: "$_.EmailAdresses" isn't a valid SMTP address. The domain name can't contain spaces and it has to have a prefix and a suffix, such as example.com."     + CategoryInfo          : InvalidData: (:) [Set-DistributionGroup], ParameterBindin...mationException     + FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-DistributionGroup     + PSComputerName        : XXXXXX.XXXXXX.local

    .csv file

    Identitys

    EmailAddressess

    Tuesday, October 29, 2019 8:24 PM
  • you csv must be :

    identitys,EmailAdresses
    it@consto.com,support@contoso.com
    it@consto.com,support@fabrikam.com

    made it with notepad; no space.

    Tuesday, October 29, 2019 8:50 PM
  • Remove the single quotes surrounding the $_.EmailAddresses variable.

    Posting the code you're using in addition to the error would be appropriate.


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Tuesday, October 29, 2019 9:14 PM
  • how .csv look in excel?
    Tuesday, October 29, 2019 9:17 PM
  • this is Exchange 2016
    Tuesday, October 29, 2019 10:09 PM
  • Hi,

    Csv looks just like the excel table in excel. They have column title and values.

    Please post the code you have tried for better help. 

    Best regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, October 30, 2019 7:49 AM