Solved

import list of users to Dirstrubition list

Posted on 2015-02-03
11
116 Views
Last Modified: 2015-04-13
Hi Guys,

I am running Windows server 2008R2 and AD 2008 . I need to import emails address to one of the DL which is already created
Total of the users are about 1000, and I have them in Excel file.
IS any way I can import them by using power shell Script .
Please provide me with step by step on how to run the file and script as I am new.

I appreciate your help , if you can send me a good link also how to start to work with PS 

Thanks you in advance
0
Comment
Question by:Rabihhaj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 9

Expert Comment

by:Benjamin MOREAU
ID: 40587393
0
 

Assisted Solution

by:Rabihhaj
Rabihhaj earned 0 total points
ID: 40587414
Thanks for the link and quick response

I am using this script at the moment and I got it to work last year and I forget how to run it etc

Import-CSV email.csv | ForEach {Add-DistributionGroupMember -Identity "testdl" -Member $_.Name}

please let me know what is the issue

Thanks
0
 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 400 total points
ID: 40587470
Add-DistributionGroupMember is a Exchange management shell Cmdlet. You need to run the code from Exchange management Shell. Also the input csv file should be in following format.
Name
UserA@domain.com
UserB@domain.com
UserC@domain.com

Open in new window

Code
Import-CSV email.csv | ForEach {Add-DistributionGroupMember -Identity "testdl" -Member $_.Name}

Open in new window

0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:Rabihhaj
ID: 40587612
HI ,
it is working
but ,I am getting a lots of object could not find when I run the above script
is any way I can export that DL to bring me All Emails address and logonID,  if that possible

At the present I am using the below script and only give me display name and OU
dsquery group -name "testsl" | dsget group -members -expand >"name.txt"
please advise

[PS] H:\>.\EmailToDL.ps1
Couldn't find object "NAme@Domain.com". Please make sure that it was spelled correctly or specify a differe
nt object.
    + CategoryInfo          : NotSpecified: (0:Int32) [Add-DistributionGroupMember], ManagementObjectNotFoundException
    + FullyQualifiedErrorId : E9688D04,Microsoft.Exchange.Management.RecipientTasks.AddDistributionGroupMember
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40587866
Try..
Get-DistributionGroupMember testsl | Select SamAccountName,PrimarySmtpAddress | Export-csv C:\testsl.csv -nti

Open in new window

0
 

Author Comment

by:Rabihhaj
ID: 40589612
Hi Subsun,
last request ....

You did well. how about if I need to get the Full name or display name .
what do I have to add in this script

do you know why I am getting "Couldn't find object "NAme@Domain.com". Please make sure that it was spelled correctly or specify a differe
 nt object."

Please advise

Thanks
rabih
0
 
LVL 40

Accepted Solution

by:
Subsun earned 400 total points
ID: 40589913
how about if I need to get the Full name or display name .
Based on the attribute required, you need to add it to the Select command, for example to get displayame
Get-DistributionGroupMember testsl |  Select SamAccountName,PrimarySmtpAddress,DisplayName | Export-csv C:\testsl.csv -nti

Open in new window


If NAme@Domain.com is available but still gets error, probably there will be trailing space added to the data entered in csv file.
Try..
Import-CSV email.csv | ForEach {Add-DistributionGroupMember -Identity "testdl" -Member $_.Name.Trim()}

Open in new window


Other possibility is, the NAme@Domain.com is located in a different domain, so you need to set the RecipientViewRoot to root of the forest,,
Set-AdServerSettings -ViewEntireForest $true
Import-CSV email.csv | ForEach {Add-DistributionGroupMember -Identity "testdl" -Member $_.Name.Trim()}

Open in new window

0
 

Author Closing Comment

by:Rabihhaj
ID: 40607527
My Script is working , it was an error in the File where the data coming from


Subsun , Excellent response  and quick reply
0
 

Author Comment

by:Rabihhaj
ID: 40720290
Hi Subsun ,

Could you please assist me with your Scripts

It is working but not on the Destrubution lists who has sub distribution list nest it
Get-DistributionGroupMember testsl | Select SamAccountName,PrimarySmtpAddress | Export-csv C:\testsl.csv -nti

could you please kindly  have a look if you can provide me with the script  it does exports all users who are member and member of DL

Thanks
Rabih
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40720658
There is no option to find recursive members with Get-DistributionGroupMember.. You can try with AD Powershell..

Import-Module Activedirectory
Get-ADGroupMember testsl -Recursive | Get-ADUser -pr * | Select SamAccountName,Mail | Export-csv C:\testsl.csv -nti

Open in new window


In future, please open a new question for additional requests..
0
 

Author Comment

by:Rabihhaj
ID: 40721935
Thank you and I will do it next time .
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

734 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