• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1594
  • Last Modified:

Exchange 2007 Import multivalued proxyaddresses

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
adkwinadmin
Asked:
adkwinadmin
  • 4
  • 4
1 Solution
 
endital1097Commented:
you need to run
Set-Distribution $temp -EmailAddresses $temp.EmailAddresses
0
 
adkwinadminAuthor Commented:
Also, here is a sample of the CSV format:

alias,proxyAddresses
abuse,smtp:abuse@domainA.com;smtp:testman@domainB.com
0
 
crimmelCommented:
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
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
adkwinadminAuthor Commented:
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
 
endital1097Commented:
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
 
endital1097Commented:
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
 
adkwinadminAuthor Commented:
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
 
endital1097Commented:
sorry i had a typo
should be $p in $proxys
forgot the s
0
 
adkwinadminAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell┬« is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now