Solved

import list of users to Dirstrubition list

Posted on 2015-02-03
11
107 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

948 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

23 Experts available now in Live!

Get 1:1 Help Now