Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

import list of users to Dirstrubition list

Posted on 2015-02-03
11
Medium Priority
?
128 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 10

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 1600 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
WatchGuard Case Study: Museum of Flight

“With limited money and limited staffing, we didn’t have a lot of choices in terms of what we could do to bring efficiency. WatchGuard played a central part in changing that.” To provide strong, secure Wi-Fi access within the museum, Hunter chose to deploy WatchGuard’s AP120 APs.

 

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 1600 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

WatchGuard Case Study: NCR

With business operations for thousands of customers largely depending on the internal systems they support, NCR can’t afford to waste time or money on security products that are anything less than exceptional. That’s why they chose WatchGuard.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
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…
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…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

916 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