Adding a list of users in Distribution list using power shell script

Hi All,

I am running Windows Server 2008 and I need to create a DL in Exchange 2010

Is any way I can add a 100 users to DL using a script to do that
Please help me with step by step as I am a new to script
I prefer using PS or command line like DSquery Etc…
Or if there is  other sample way to do it in Active Directory

Thank you in advance
RabihhajIT HelpDeskAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brendanmeyerCommented:
try
Import-CSV FileName.csv | ForEach {Add-DistributionGroupMember -Identity "GROUP-NAME" -Member $_.Name}

Open in new window


having each name on a line in the csv file
0
RabihhajIT HelpDeskAuthor Commented:
Hi Brendanmeyer,

Do You mean in PS or Command line

How about the name , Is that First name and last name  in the CSV file is any ; or , at the ends of each line

Could you please send me some example or link
I approciate you comment and help
0
brendanmeyerCommented:
this is in powershell

do you have the users usernames or full names?

if usernames
create a txt file with each username on a line (save it as FileName.csv) in the directory that your powershell it running at

in the command above change GROUP-NAME to the actual name of the group tou are trying to add the users to

eg:
FileName.csv
bobb
scottc

from powershell
Import-CSV FileName.csv | ForEach {Add-DistributionGroupMember -Identity "execs" -Member $_.Name}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

RabihhajIT HelpDeskAuthor Commented:
Hi  brendanmeyer,

What i found out on the server , MS office not Install on the server , is any other way to create the file with TXT file instead CSV.

I look at the import-??? can not find TXT command for it in PS .

Please help
0
brendanmeyerCommented:
well yeah

just create a text file with the names on each line.
and then just rename from
names.txt to names.csv
0
RabihhajIT HelpDeskAuthor Commented:
Hi ,
thank you for your quick response. I will try this tomorrow and let you know ...

that only part I am not sure is where do i save the file and how do i find out  where is my PS is running.

"(save it as FileName.csv) in the directory that your powershell it running at
"
i tried this at my home PC , is this the correct path, where i should save the file and run the scripts

C:\Windows\System32\WindowsPowerShell\v1.0

Thanks
Rabih
0
RabihhajIT HelpDeskAuthor Commented:
Hi  brendanmeyer,

I tried the above and it worked , now if i only have an email address can i add them to the DL by inport Email address instead Name.

Do  i have to  change any things in the scripts

Thansk
Rabih
0
brendanmeyerCommented:
it should work fine
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.