Oct 12 2019
06:59 AM
- last edited on
Feb 06 2023
04:13 AM
by
TechCommunityAP
Oct 12 2019
06:59 AM
- last edited on
Feb 06 2023
04:13 AM
by
TechCommunityAP
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
Oct 12 2019 07:14 AM
@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]
Oct 12 2019 07:35 AM
@DanielNiccoli : 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
Oct 12 2019 08:55 AM
Solution@Test SharePointThen either your csv file is malformed, or you need to modify the Import-Csv parameters.
Oct 15 2019 10:42 AM
Jan 18 2021 10:59 AM
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
Feb 02 2021 03:42 AM
Mar 16 2021 01:32 PM
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
Mar 16 2021 02:46 PM
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.
Mar 16 2021 03:20 PM
Jun 20 2024 12:18 PM
@DanielNiccoli i fixed the issue,
I had to put the actual name of what the -member $_email for example so in the excel sheet had to insert line that said email in line 1 and all the email addresses underneath that and it work imported 67 members at once to the distro group
Oct 12 2019 08:55 AM
Solution@Test SharePointThen either your csv file is malformed, or you need to modify the Import-Csv parameters.