Now that you have (or will have) a usable CSV file (https://en.wikipedia.org/wiki/Comma-separated_values):
Import-Csv tt.csv |
ForEach-Object{
Add-DistributionGroupMember -identity "DL Identity Goes Here" -member $_.Email
}
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am looking for a power shell command to add bulk of users into DL (Exchange Online). I have a CSV file contain the users and email address.
I appreciate your kind help
Now that you have (or will have) a usable CSV file (https://en.wikipedia.org/wiki/Comma-separated_values):
Import-Csv tt.csv |
ForEach-Object{
Add-DistributionGroupMember -identity "DL Identity Goes Here" -member $_.Email
}
Hi @IT,
If the format of csv file is like:
You can run the following script to bulk add users:
(replace $member.Email with the corresponding column header in your csv file, for example if the header is "EmailAddress", you need to use $member.EmailAddress)
$members = import-csv users.csv
foreach($member in $members)
{
Add-DistributionGroupMember -identity "DL email address" -member $member.Email
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
If the screenshot of your "csv", viewed in Excel, looks like below, then expand the width of column "A" and I think you'll see that all of your data are in only one column.
If you exported that to a CSV format you'd have a text file that looks like this:
"Name,Email"
"""ParentUK1"",""******@uk.co.uk"""
If you were to import that using Import-CSV you'd get PSCustombjects with only one property: Name,Email and, as a value for that property you'd see "ParentUK1","******@uk.co.uk".
As a result, there's no "Email" property, nor a "Name" property.
If all of that is not what you're dealing with, then we need to see the contents of (say) the first three lines of the file "tt.csv". You can use Get-Contents tt.csv | select-object -first 3 to do that.