Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Add existing external contacts to distribution list with PowerShell

Posted on 2014-01-02
6
Medium Priority
?
3,956 Views
Last Modified: 2014-01-05
hey guys,

I have an Exchange 2010 server that I have imported some external contacts into an OU in AD using PowerShell and now I want to add all contacts in that OU to a distribution list.

I cant seem to add external mail contacts to the distribution list using PowerShell, only domain users. I can do it using the AD management console but I want to script this process hence why I am trying to do it with PowerShell.

Because of the problems I have encountered, to simplify things I am trying to add just one contact to the DL before trying to add the whole OU again. I have tried using the Name, DistinguishedName, Identity and even WindowsEmailAddress after the -member switch but nothing works.

Here is the single command I have been issuing and here is the output.
Add-DistributionGroupMember "All Suppliers" -member "CN=Supplier,OU=All Suppliers,OU=Domain Users,DC=domain,DC=local"
Couldn't find object "domain.local/Domain Users/All Suppliers/Supplier". Please make sure that it was spelled correctly or 
specify a different object.
    + CategoryInfo          : NotSpecified: (0:Int32) [Add-DistributionGroupMember], ManagementObjectNotFoundException
    + FullyQualifiedErrorId : F5A15BE2,Microsoft.Exchange.Management.RecipientTasks.AddDistributionGroupMember
    + PSComputerName        : mail.domain.local

Open in new window


Is there a different command that I cant find any documentation on to add contacts to a DL from PowerShell? I haven't been able to find one in all my googling.

Thanks in advance.
AC
0
Comment
Question by:defecta
[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 Comments
 
LVL 21

Accepted Solution

by:
Jeremy Weisinger earned 1800 total points
ID: 39753157
You need to mail enable the contacts if you want to use the Exchange cmdlet.

http://technet.microsoft.com/en-us/library/bb124237.aspx

Once the contact is mail enabled you should be able to add it using that command.

The equivalent of what you're doing in AD is the Add-ADGroupMember cmdlet.
http://technet.microsoft.com/en-us/library/ee617210.aspx
0
 

Author Comment

by:defecta
ID: 39753534
Dsnegi_25dec I have seen that thread which I was using as the basis of my script. With the exception of importing contacts from a CSV first I have been following the same steps and it doesn't work. Perhaps for the reasons Jeremy was alluding to.

Jeremy, I am yet to do as you have suggested but before I do, can you explain why I can add the same contacts to the distribution list without mail enabling them using the GUI but not via the shell?
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 37

Assisted Solution

by:Jamie McKillop
Jamie McKillop earned 200 total points
ID: 39754718
Hello,

The reason you can add them in the GUI is that you are using a completely different tool. ADUC doesn't care that they aren't mail enabled. From its perspective, you are just adding a user to a group. The Exchange tools will only allow you to add mail-enabled objects to distribution groups.

-JJ
0
 
LVL 21

Expert Comment

by:Jeremy Weisinger
ID: 39755608
Thanks JJ, exactly what I was going to say.

Defecta, for Exchange to utilize the contacts and send to them, they need to be mail enabled. So what you did in ADUC won't have any affect unless those objects are already mail enabled.
0
 

Author Closing Comment

by:defecta
ID: 39758411
Thanks guys, i never did test sending email to the contacts until after I questioned what you said. Of course you were right.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

661 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