SOLVED

How to bulk add external recipients to an Office365 Distribution List?

Copper Contributor

Hello,

 

I'm trying  to add our email addresses (external addresses) to a Distribution List in Office365.

 

I've followed this link  https://answers.microsoft.com/en-us/msoffice/forum/all/how-to-bulk-add-external-recipients-to-an/765... and got to #2 in the powershell code below. However, in powershell I am getting the error message The '<' operator is reserved for future use , after I paste line 2. Any ideas?

 

  1. $Members = Import-Csv D:\ExternalContacts.csv
  2. $Members | ForEach {Add-DistributionGroupMember -Identity <TestDL> -Member $_.DisplayName}
  3. Get-DistributionGroupMember -Identity <TestDL>

 

5 Replies
You have to remove '<` and `>`, for example:
$Members | ForEach {Add-DistributionGroupMember -Identity TestDL -Member $_.DisplayName}

Thanks for responding @Ricardo Viana , I'll give it a try.

Hi @Ricardo Viana 

I'm now receiving the below message for Line 2 . Currently I only have Data in the ExternalEmailAddress and Name fields within the excel sheet.  Which field is Member looking for

 

Cannot validate argument on parameter 'Member'. The argument is null. Provide a valid value for the argument, and then try running the command again.
+ CategoryInfo : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Add-DistributionGroupMember
+ PSComputerName : outlook.office365.com

best response confirmed by Kristopherw (Copper Contributor)
Solution
That cmdlet is gathering the data from Displayname column from the CSV (-Member $_.DisplayName), you will need to change the column or the script.

eg:.
$Members | ForEach {Add-DistributionGroupMember -Identity TestDL -Member $_.ExternalEmailAddress}

Hi @Ricardo Viana , 

 

Many thanks, this worked!

1 best response

Accepted Solutions
best response confirmed by Kristopherw (Copper Contributor)
Solution
That cmdlet is gathering the data from Displayname column from the CSV (-Member $_.DisplayName), you will need to change the column or the script.

eg:.
$Members | ForEach {Add-DistributionGroupMember -Identity TestDL -Member $_.ExternalEmailAddress}

View solution in original post