SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-910637%22%20slang%3D%22en-US%22%3ETrying%20to%20add%20multiple%20users%20to%20distribution%20group%20and%20getting%20error%3A%20Cannot%20validate%20argument%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-910637%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20add%20multiple%20users%20in%20a%20distribution%20Group.%3C%2FP%3E%3CP%3EAll%20users%20are%20in%20cloud.%3C%2FP%3E%3CP%3EI%20have%20a%20CSV%20which%20has%20the%20following%20columns%20%3A%3C%2FP%3E%3CP%3EDisplayName%2C%20Alias%2C%20PrimarySmtpAddress%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20the%20following%20script%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24Userslist%20%3D%20Import-CSV%20c%3A%5Cusers%5Cuser%5Cab.csv%3CBR%20%2F%3EForEach%20(%24User%20in%20%24Userslist)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EAdd-DistributionGroupMember%20-Identity%20%22Office%22%20-Member%20%24User.PrimarySmtpAddress%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20getting%20the%20following%20error%3A%3C%2FP%3E%3CP%3ECannot%20validate%20argument%20on%20parameter%20'Member'.%20The%20argument%20is%20null.%20Provide%20a%20valid%20value%20for%20the%20argument%2C%20and%20then%20try%20running%20the%20command%20again.%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20InvalidData%3A%20(%3A)%20%5BAdd-DistributionGroupMember%5D%2C%20ParameterBindingValidationException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20ParameterArgumentValidationError%2CAdd-DistributionGroupMember%3CBR%20%2F%3E%2B%20PSComputerName%20%3A%20outlook.office365.com%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eany%20help%20would%20be%20appreciated%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-910637%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDistribution%20Group%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%20Powershell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EUsers%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-910658%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20add%20multiple%20users%20to%20distribution%20group%20and%20getting%20error%3A%20Cannot%20validate%20argument%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-910658%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F163419%22%20target%3D%22_blank%22%3E%40Test%20SharePoint%3C%2FA%3ESomething%20breaks%20during%20import.%20%22Cannot%20validate%20argument%20on%20parameter%20'Member'.%20The%20argument%20is%20null.%22%20Null%20means%20that%20it%20couldn't%20parse%20the%20csv%2C%20otherwise%20it%20would%20be%20an%20empty%20string.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHave%20you%20confirmed%20that%20the%20import%20actually%20works%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%24Userslist%20%3D%20Import-CSV%20c%3A%5Cusers%5Cuser%5Cab.csv%0A%0A%24Userlist%0A%0A%24Userlist%5B0%5D%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-910663%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20add%20multiple%20users%20to%20distribution%20group%20and%20getting%20error%3A%20Cannot%20validate%20argument%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-910663%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F65328%22%20target%3D%22_blank%22%3E%40Daniel%20Niccoli%3C%2FA%3E%26nbsp%3B%3A%20thanks%20for%20your%20reply.%20I%20tried%20the%20above%20command%20and%20get%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECannot%20index%20into%20a%20null%20array.%3CBR%20%2F%3EAt%20line%3A1%20char%3A1%3CBR%20%2F%3E%2B%20%24Userlist%5B0%5D%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20InvalidOperation%3A%20(%3A)%20%5B%5D%2C%20RuntimeException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20NullArray%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-910721%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20add%20multiple%20users%20to%20distribution%20group%20and%20getting%20error%3A%20Cannot%20validate%20argument%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-910721%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F163419%22%20target%3D%22_blank%22%3E%40Test%20SharePoint%3C%2FA%3EThen%20either%20your%20csv%20file%20is%20malformed%2C%20or%20you%20need%20to%20modify%20the%20Import-Csv%20parameters.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-916045%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20add%20multiple%20users%20to%20distribution%20group%20and%20getting%20error%3A%20Cannot%20validate%20argument%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-916045%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F65328%22%20target%3D%22_blank%22%3E%40Daniel%20Niccoli%3C%2FA%3E%26nbsp%3B%3A%20thank%20you..%20i%20created%20a%20new%20csv%20and%20that%20worked.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
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

4 Replies
Highlighted

@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]
Highlighted

@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

Highlighted
Solution

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

Highlighted

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