Solved

Creating Distribution Groups in PS

Posted on 2016-11-22
2
55 Views
Last Modified: 2016-11-30
I have been using this with great success but now I am coming up on some very large DGs that I need to create and was wondering what the best way to create the DL if I have all the email addresses in a CSV.  Could someonw point me in the right direction?

New-DistributionGroup -Name "Intelerad Group" -Members chris@contoso.com,michelle@contoso.com,laura@contoso.com,julia@contoso.com
0
Comment
Question by:SDISupport
2 Comments
 
LVL 19

Assisted Solution

by:Peter Hutchison
Peter Hutchison earned 250 total points
ID: 41898712
You could use an simple import routine from a file and add the members from the CSV:
Param($file)
$userlist = Import-CSV $file
$groupname = "My group"

Foreach ($user in $userlist) {
  Add-DistributionGroupMember -Identity $groupName -Member ($user.Identity)
}
0
 
LVL 36

Accepted Solution

by:
Mahesh earned 250 total points
ID: 41900116
Try below

# Create csv file with Email as header and add all members email address underneath

Import-Module ActiveDirectory

$groupName = "YourGroupName"

$memberlist = Import-Csv "C:\memberlist.csv"

foreach ($member in $memberlist) {

$emailusers = Get-ADUser -Filter { (mail -eq $member.email) } -SearchBase "DC=domain,DC=com" -SearchScope SubTree

if ($emailusers -ne $null)

{ Add-ADGroupMember -Identity $groupName -Member $($emailusers.SamAccountName)

    }

}

Open in new window

0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
In this video we show how to create a Distribution Group in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >>…
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question