Solved

import list of users to Dirstrubition list

Posted on 2015-02-03
11
104 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
  • 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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now