Solved

Exchange 2007 Import multivalued proxyaddresses

Posted on 2010-08-20
9
1,559 Views
Last Modified: 2012-06-22
I have a csv containing an alias, and a proxyaddresses field which was from an AD dump.

I need a script to ADD (not replace) all of the addresses listed in the proxyaddresses field.  Some only have a few addresses, some have many.

I have several hundred distributiongroups that I have to add these two so I don't want to do it by hand.

I have sampled the following below but it doesn't like the fact that it has multiple values in the proxyaddress field.

Import-CSV C:\bah8.csv | foreach {
$Temp = Get-DistributionGroup -identity $_.alias
$Temp.EmailAddresses += $_.proxyaddresses
set-distributiongroup -instance $temp}

I have also tried removing the smtp: and replacing the ; with a comma, but it still thinks it's invalid.
Please advise!
0
Comment
Question by:adkwinadmin
[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
  • 4
  • 4
9 Comments
 
LVL 32

Expert Comment

by:endital1097
ID: 33485337
you need to run
Set-Distribution $temp -EmailAddresses $temp.EmailAddresses
0
 

Author Comment

by:adkwinadmin
ID: 33485384
Also, here is a sample of the CSV format:

alias,proxyAddresses
abuse,smtp:abuse@domainA.com;smtp:testman@domainB.com
0
 
LVL 4

Expert Comment

by:crimmel
ID: 33485826
First off, Set-DistributionGroup is what you want to use.  Not Set-Distribution.

Second, the collection of proxyAddresses needs to have a primary address for each address type.  You indicate primary by capitalizing the type.  Using your example above, it should read like this:

alias,proxyAddresses
abuse,SMTP:abuse@domainA.com;smtp:testman@domainB.com

Notice that the first SMTP in the list is now capitalized.
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:adkwinadmin
ID: 33485865
I just want to add these smtp addresses to the pertaining distribution group, I don't want to change the primary address that has been laid down by the policy.  
0
 
LVL 32

Accepted Solution

by:
endital1097 earned 500 total points
ID: 33485892
ahh, thanks


Import-CSV C:\bah8.csv | foreach {
$Temp = Get-DistributionGroup -identity $_.alias
$proxys = $_.proxyaddresses.split(";")
foreach($p in $proxy) { $Temp.EmailAddresses += $p }
set-distributiongroup $temp -EmailAddresses $temp.emailaddresses }

Open in new window

0
 
LVL 32

Expert Comment

by:endital1097
ID: 33485910
because your csv has multivalues you need to create an array variable by splitting the value using your separator
hence split(";")
then you need to add each value of the array
0
 

Author Comment

by:adkwinadmin
ID: 33485971
endital1097, when i run your script I get the following:

Exception setting "EmailAddresses": "Cannot convert value "System.Object[]" to
type "Microsoft.Exchange.Data.ProxyAddressCollection". Error: "Value cannot be
null.
Parameter name: item""
At C:\bah8.csv.ps1:4 char:31
+ foreach($p in $proxy) { $Temp. <<<< EmailAddresses += $p }
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException
0
 
LVL 32

Expert Comment

by:endital1097
ID: 33486033
sorry i had a typo
should be $p in $proxys
forgot the s
0
 

Author Closing Comment

by:adkwinadmin
ID: 33486095
Fantastic work!  Please use this solution as well as your typo correction.  I cannot believe that nobody else has requested this type of solution for an AD dump and import.

But you saved me HOURS of work!  Thanks!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

733 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