Solved

import list of users to Dirstrubition list

Posted on 2015-02-03
11
120 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
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…
Suggested Courses

617 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