Solved

Adding additional SMTP Proxy address

Posted on 2010-11-09
39
3,226 Views
Last Modified: 2012-05-10
Good day experts.  I am working on a task that require the following;

We currently have numerous proxy addresses in our domain
for example:
Fn.Ln@mickey.com
Fn.Ln@Donald.com
Fn.Ln@Snoopy.com
Fn.Ln.@Minnie.com

We have a new requirement to add an additional proxy address "Fn.Ln@Disney.com" to all accounts, but first I have to export all customers with Fn.Ln@mickey.com and ensure no duplicates will be created

Can someone provide a script or  that can export all Fn.Ln@mickey.com address from my org, and export to a csv file.  then an import script to import the edited csv and also add the additional proxy address of Fn.Ln@Disney.com.  

BTW, the Fn.Ln@Disney.com will not be the primary address as of yet.
0
Comment
Question by:DreRasta
  • 20
  • 17
  • 2
39 Comments
 
LVL 31

Expert Comment

by:Justin Owens
ID: 34095930
To save you some trouble, are these AD Users or are they AD Contacts?  You cannot have duplicate SMTP Address if they are Users, but you can if they are Contacts.  That is why I ask.

As far as the export, what version of Exchange are you using and in what language to you want the script?
0
 
LVL 27

Accepted Solution

by:
KenMcF earned 500 total points
ID: 34095939
This would be pretty easy with powershell and the quest AD cmdlets
http://www.quest.com/powershell/activeroles-server.aspx
The first will pull all the addresses and put them in this format
samaccount,proxyaddress

The second will put new address in

If you want to clear you can use
clear-qadproxyaddress USERNAME ADDRESS

$out = @()
$out += "name,Proxy"
$users = get-qaduser -sizelimit 0 -includedproperties proxyaddresses 
    Foreach ($user in $users){
        Foreach($p in $user.Proxyaddresses){
        $out += "$($user.samaccountname),$($p)"
        }
    }
$out | out-file c:\users.csv
    
    
 $users = import-csv c:\users.csv
 foreach($user in $users){
 get-qaduser $user.name | add-qadproxyaddress $user.name $user.Proxy 
 }

Open in new window

0
 

Author Comment

by:DreRasta
ID: 34096072
Yes, these are AD users.  I have downloaded the Quest AD cmdlets, but never used or have not taught myself Quest AD cmdlets yet
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 31

Expert Comment

by:Justin Owens
ID: 34096161
Are you familiar with PowerShell in general?
0
 

Author Comment

by:DreRasta
ID: 34096240
yes I am.  I believe I had downloaded Quest Ad a few months ago.  attempting previous suggestion hopefully in the next hour
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34096271
the quest ad cmdlets are pretty easy to use and have good help files. For a good reference you could do this

make a dir call c:\qad
get-command *qad* | %{get-help $_.name -full >c:\qad\$_.txt}
0
 

Author Comment

by:DreRasta
ID: 34096816
I ran the suggested cmd and it provided an out csv with over 43000 lines of results.  This is good, but it also provided all the smtp address for other address space

For example, I would like to pull all customer mailboxes that have a @mickey.com address.  I am not to concerned about the x500, x400, or any other address, just the customers with @mickey.com

Also the output file, if I could get it to have two or more columns, DisplayName, SMTP address, Primary address that would be easier to sort and verify possible duplication.  Thank you for all your assistance thus far, it is greatly appreciated
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34096861
Try to replace the current foreach with this one.

Foreach($p in $user.Proxyaddresses){
If($p -match "@mickey.com"){
$out += "$($user.samaccountname),$($p),$($user.mail)"
}}
0
 

Author Comment

by:DreRasta
ID: 34121389
Are you saying to perform the following
$out = @()
$out += "name,Proxy"
$users = get-qaduser -sizelimit 0 -includedproperties proxyaddresses
    Foreach ($user in $users){
        Foreach($p in $user.Proxyaddresses){
        $out += "$($user.samaccountname),$($p)"
        }
    }
$out | out-file c:\users.csv
   
   
 $users = import-csv c:\users.csv
 foreach($user in $users){
 get-qaduser $user.name | add-qadproxyaddress $user.name $user.Proxy
 }
 
When would I place the new piece of script as listed below

Foreach($p in $user.Proxyaddresses){
If($p -match "@mickey.com"){
$out += "$($user.samaccountname),$($p),$($user.mail)"
}}
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34121531
replace the current foreach loop like this
$out = @()
$out += "name,Proxy"
$users = get-qaduser -sizelimit 0 -includedproperties proxyaddresses
	Foreach($p in $user.Proxyaddresses){
		If($p -match "@mickey.com"){
		$out += "$($user.samaccountname),$($p),$($user.mail)"
	}}
$out | out-file c:\users.csv

Open in new window

0
 

Author Comment

by:DreRasta
ID: 34147117
Okay, I was able to pull the obtain the information and sort via the newly created csv file.  
You listed above to add the new address use the following;

$users = import-csv c:\users.csv
 foreach($user in $users){
 get-qaduser $user.name | add-qadproxyaddress $user.name $user.Proxy
 }

Where do I add in the new smtp:Fn.Ln@Disney.com.  Also, I just want to add this additional address, and not make it the Primary SMTP: address
0
 
LVL 27

Assisted Solution

by:KenMcF
KenMcF earned 500 total points
ID: 34147217
You would need your CSV file to look like this

NAME,PROXY
User1,USer1@Disney.com
User2,USer2@Disney.com


Also change this line

get-qaduser $user.name | add-qadproxyaddress $user.name $user.Proxy

to this

get-qaduser $user.name | add-qadproxyaddress -Address $user.Proxy -type SMTP
0
 

Author Comment

by:DreRasta
ID: 34147477
importtet.csv has customers
wining,dave.wining@disney.com  - Recevied the following errors

[PS] C:\Documents and Settings\ess-faceya> $users = import-csv c:\scripts\doegov\importtest.csv [PS] C:\Documents and Settings\ess-faceya> foreach($user in $users){
>>  get-qaduser $user.name | add-qadproxyaddress -Address $user.Proxy
>> -type SMTP  }
>>
Get-QADUser : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At line:2 char:13
+  get-qaduser <<<<  $user.name | add-qadproxyaddress -Address
+ $user.Proxy -type SMTP
    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet
   s.GetUserCmdlet
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34147565
Did you put the header fields in the CSV

NAME,PROXY

if you just do
import-csv c:\users.csv
you should get a list with the header fields.
0
 

Author Comment

by:DreRasta
ID: 34147693
You are correct, I do receive a list with the header fields, but I continue to receive the Cannot validate arugument on parameter identity
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34147720
See what you get with this

$users = import-csv c:\scripts\doegov\importtest.csv
foreach($user in $users){
$user.name
}

The output you get, is that a valid user name?

try one of the outputs in place of USERNAME

get-qaduser USERNAME
0
 

Author Comment

by:DreRasta
ID: 34147856
[PS] C:\Documents and Settings\ess-faceya>$users = import-csv c:\scripts\doegov\importtest.csv foreach($user in $users){
 $user.name }
Unexpected token 'in' in expression or statement.
At line:1 char:70
+ $users = import-csv c:\scripts\doegov\importtest.csv foreach($user in <<<<  $users){ $user.name }
    + CategoryInfo          : ParserError: (in:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken


name,Proxy            
kingac,Ari.Kig@disney.com      
wining,Dave.Wining@disney.com

0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34147894
I can not tell from your output but it looks like it may be a single line, it should be 3 lines.

$users = import-csv c:\scripts\doegov\importtest.csv
foreach($user in $users){
$user.name}
0
 

Author Comment

by:DreRasta
ID: 34147959
It was one line, but I have made it three.   the script ran with no errors but no changes occurred
0
 
LVL 27

Assisted Solution

by:KenMcF
KenMcF earned 500 total points
ID: 34148070
Just to make sure this is the one you are running? Each is a seperate line.

$users = import-csv c:\users.csv
 foreach($user in $users){
 get-qaduser $user.name | add-qadproxyaddress -Address $user.Proxy -type SMTP
 }

0
 

Author Comment

by:DreRasta
ID: 34148607
Yes, I am running the below on separte lines.  I am cutting and pasting the below into the Active Roles Mgmt Shell

$users = import-csv c:\scripts\doegov\importtest2.csv
 foreach($user in $users){
 get-qaduser $user.name | add-qadproxyaddress -Address $user.Proxy -type SMTP
 }
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34148632
Can you test just one

get-qaduser USERNAME | add-qadproxyaddress -Address USERNAME@Disney.com -Type SMTP
0
 

Author Comment

by:DreRasta
ID: 34148967
[PS] C:\Documents and Settings\ess-faceya>get-qaduser kingac | add-qadproxyaddress -Address kingac@doe.gov -Type smtp

Name                           Type            DN
----                           ----            --
King, Richard                  user            CN=King\, Richard,OU=Accounts,OU=IM-60 Operations,OU=IM,OU=Orgs,OU=HQ...
Add-QADProxyAddress : The e-mail address settings cannot be applied. Primary address is not specified for these address
 types: X500. For each address type, a certain e-mail address of that type should be set as primary.
At line:1 char:41
+ get-qaduser kingac | add-qadproxyaddress <<<<  -Address kingac@doe.gov -Type smtp
    + CategoryInfo          : NotSpecified: (DOE\kingac:ArsUserObject) [Add-QADProxyAddress], ProxyAddressException
    + FullyQualifiedErrorId : Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.AddProxyAddressCommand
0
 

Author Comment

by:DreRasta
ID: 34148977
I do appreciate your patience and help on this matter
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34149064
Does that account have a primary SMTP addresss set?

from the error it sounds like this account does not have one set.
0
 

Author Comment

by:DreRasta
ID: 34149186
Yes it has an primary SMTP address set.  

Some of my customers may have the following

smtp:   Fn.LN@Goofy.com
smtp:  alias@mickey.com
SMTP:  Fn.Ln@mickey.com    primary address


I want to add another address (Not Primary)

smtp:  Fn.Ln@Disney.com
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34149238
Can you run this to see what output it gives you.

(get-qaduser kingac).proxyaddresses | %{$_}
0
 

Author Comment

by:DreRasta
ID: 34149421
[PS] C:\Documents and Settings\ess-faceya>(get-qaduser kingac).proxyaddresses | %{$_}
x500:/O=DOL/OU=ALOMAIL/cn=Recipients/cn=richard.king2.hq.com
X400:C=US;A= ;P=Dep of En;O=HumanResources;S=King;G=Aric;
x400:C=US;A= ;P=Dep of En;O=HumanResources;S=King;G=Richard;I=A;
smtp:Richard.King2@hq.com
SMTP:Aric.King@hq.com
MBX:1
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34149489
It is having problems with the x.500 address. If you go into that account is the x.500 address maked as the primary for x.500?
0
 

Author Comment

by:DreRasta
ID: 34149534
I only have one x500 address in the email address tab
0
 

Author Comment

by:DreRasta
ID: 34149603
And it is not Set as primary for the x500
0
 
LVL 27

Assisted Solution

by:KenMcF
KenMcF earned 500 total points
ID: 34149610
Is that maked as primary?

I do not have any x.500 addresses to test in my dev env right now. Not sure why it is giving that error. Do you have any account without the x.500 to test?
0
 

Author Comment

by:DreRasta
ID: 34149648
unfortunately no.  all my customers have multiple smtp, and x400 and one x500 addresses
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34149670
Can you test setting one as primary, then running the command again on a signle account?
0
 

Author Comment

by:DreRasta
ID: 34149707
Wow, amazingly I set the X500 address as primary and ran
get-qaduser kingac | add-qadproxyaddress -Address kingac@doe.gov -Type SMTP

and it worked
0
 

Author Comment

by:DreRasta
ID: 34149845
So yes doing it in a single user fashion will work, but I have over 10000 customers to add this additional address to.

0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34149936
let see if there is a way to set these to primary.
0
 
LVL 27

Assisted Solution

by:KenMcF
KenMcF earned 500 total points
ID: 34154130
Take a look at this link, you might be able to use ADModify to set the x500 address or add the other SMTP address. The quest cmdlets are not able to add or set x500 addresses.

http://blogs.technet.com/b/sbs/archive/2009/05/21/cannot-reply-to-old-emails-or-modify-old-calendar-items-after-pst-mail-migration.aspx
0
 

Author Comment

by:DreRasta
ID: 34156515
ZGood morning, I know I can add the additional SMTP addres via ADModify, but the problem is, I have over 10,000 in so many various OU's thus the reason, I pulled all the customers with certain smtp address @mickey.com and want to address each domain on an indivdual basis.  With ADModify, I would have to select OU's then manually sort and check each customer
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

789 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