SOLVED

Trying to add multiple users to distribution group and getting error: Cannot validate argument

Brass Contributor

I am trying to add multiple users in a distribution Group.

All users are in cloud.

I have a CSV which has the following columns :

DisplayName, Alias, PrimarySmtpAddress

 

I am trying the following script:

 

$Userslist = Import-CSV c:\users\user\ab.csv
ForEach ($User in $Userslist)
{
Add-DistributionGroupMember -Identity "Office" -Member $User.PrimarySmtpAddress
}

 

I am getting the following error:

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

 

any help would be appreciated

9 Replies

@Test SharePointSomething breaks during import. "Cannot validate argument on parameter 'Member'. The argument is null." Null means that it couldn't parse the csv, otherwise it would be an empty string.

 

Have you confirmed that the import actually works?

 

$Userslist = Import-CSV c:\users\user\ab.csv

$Userlist

$Userlist[0]

@Daniel Niccoli : thanks for your reply. I tried the above command and get this:

 

Cannot index into a null array.
At line:1 char:1
+ $Userlist[0]
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray

best response confirmed by Test SharePoint (Brass Contributor)
Solution

@Test SharePointThen either your csv file is malformed, or you need to modify the Import-Csv parameters.

@Daniel Niccoli : thank you.. i created a new csv and that worked.

 

 

Some info on exactly what you did would be helpful. I've wasted over an hour on this and I'm ready to just add the 114 people via the web interface, given there is no definitive way to validate any error message in Powershell. @Test SharePoint 

Error messages in PowerShell are mostly straight forward. He also said exactly what he did: create a valid csv file to use for the import.

@Daniel Niccoli 

 

Not really, I have also created csv file from Excel using their export function and it does not work.

 

What was the error in the creation of the csv file - or more appropriately what was the error if one follows the instructions as written in various postings, ie:

 

Alias,Name,UPN

my1.alias,My1 Aliasm,my1.alias@myserver.com

my2. ...

.. etc

@Daniel Niccoli 

 

Saved Excel file in all three available csv formats: comma-delimited, Mac and DOS. All three fails with the same error but different character location (Mac format file the outlier).

I have also used Notepad to create a generic csv file with the same outcome.

If you want help, you need to tell us the exact command and error message.
1 best response

Accepted Solutions
best response confirmed by Test SharePoint (Brass Contributor)
Solution

@Test SharePointThen either your csv file is malformed, or you need to modify the Import-Csv parameters.

View solution in original post