How to add SMTP address to proxyAddresses

How can I add an SMTP address to proxyAddresses?  I tried...

Set-ADUser -identity john.doe -add proxyAddresses = "SMPT:john.doe@domain.org"

This does not work.  I can do it manually in ADUCT under Attribute Editor in the properties of the user, but I need to do this for a large group of users.  Please no links, I'm looking for the command to use.
LVL 5
bpl5000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SubsunCommented:
Try.. (Need EMS)
Set-Mailbox subsun -EmailAddresses @{add="subsun@domain.com"}

Or

Set-Mailbox subsun -EmailAddresses @{add="subsun@domain.com","subsun@Child.domain.com"}

Open in new window

0
piattndCommented:
Try this getting the user, modifying the proxy address, then setting the user:

$user = Get-ADUser <username> -Properties mail,department,ProxyAddresses
$user.ProxyAddresses = "<primary address>"  
Set-ADUser -instance $user 

Open in new window

0
bpl5000Author Commented:
These accounts do not yet have mailboxes, but piattnd's way will work.  I tested piattnd's commands and it added the proxy address perfectly, but I need to do this for 4 thousand users.  How can I do this if I have a text file with the usernames?  The addresses that I'm trying to add are "SMTP:username@mydomain.org".  Is there anyway I can use a file to add this attribute to several users?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

bpl5000Author Commented:
I tired to separate the commands with pipes, like...

$user = Get-ADUser john.doe -Properties mail,department,ProxyAddresses | $user.ProxyAddresses = "SMTP:john.doe@mydomain.org" | Set-ADUser -instance $user

But it doesn't seem to like pipes.  If there was a way to separate commands, I could generate a file that would work for multiple accounts.
0
SubsunCommented:
If it is not a user with mailbox then you can try..
Set-ADUser subsun -Add @{ProxyAddresses="SMTP:subsun@domain.com"}

Open in new window

For bulk modification..
Import-Module Activedirectory
Import-csv C:\input.csv | % {
Set-ADUser $_.sAMAccountName -Add @{ProxyAddresses="SMTP:$($_.Email)"}
}

Open in new window

Input csv file format..
sAMAccountName,Email
User1,User1@domain.com
User2,User2@domain.com
User3,User3@domain.com

Open in new window

1
bpl5000Author Commented:
That's perfect, but since the email addresses all end with @mydomain.org, can I do something like this...

Set-ADUser $_.sAMAccountName -Add @{ProxyAddresses="SMTP:$($_.sAMAccountName)@mydomain.org"}

Also, is the $ that comes after SMTP: needed?  Is this an escape character because it's within quotes?
0
SubsunCommented:
Yes you can...
Import-Module Activedirectory
GC C:\input.txt | % {
Set-ADUser $_ -Add @{ProxyAddresses="SMTP:$_@mydomain.org"}
}

Open in new window

Input text file..
User1
User2
User3

Open in new window

Also, is the $ that comes after SMTP: needed?  Is this an escape character because it's within quotes?
inside quotes you need to specify $_.sAMAccountName as a single variable.. Else it will be considered as $_ as variable and .sAMAccountName as string..
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
piattndCommented:
If you're running exchange, why not use the recipient policy to handle this.
0
piattndCommented:
http://support.microsoft.com/kb/822447

Using the recipient policy to manage default email addresses ensures that users that match the search criteria all have AT A MINIMUM the configuration you specified.  Lets say you have 3 email addresses you want everyone to have, but one to be default.  Make a recipient policy that designates your search scope (unlimited options) and enter the address settings as required.  Anyone who meets the requirements from that point forward will automatically have their settings changed and it does support the use of reference to their login name to be in the email address.
0
piattndCommented:
One last note, recipient policy will NOT remove email addresses that you do not put in the policy.  It is meant to add or modify only, not remove email addresses.

If your policy defines email address a, b, and c, but a user has email address d currently, the user will get email addresses a, b, c, and d (the default will be the one you specify).
0
bpl5000Author Commented:
These users are not Exchange users.
0
piattndCommented:
Well then that explains that!  Bummer, would have been a more robust fix.  It looks like Subsun may have the ultimate solution for you then, though I haven't tried his code.
0
bpl5000Author Commented:
Subsun's way does work.  Piattnd's way also works and I was developing a file using semicolons to separate the commands until Subsun posted his solution.  Thanks for all the help!
0
Andy AndersonCommented:
Check out this site: https://www.365powershell.com/

They are working on a GUI to make modifying smtp email aliases / proxyAddressess quick and easy for those of us that prefer a graphical interface over command line.

I was able to get a beta release by contacting them, but they say a release candidate almost ready!  I'm also excited for the user syncback feature, been looking everywhere for that functionality.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.