Link to home
Start Free TrialLog in
Avatar of bpl5000
bpl5000

asked on

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.
Avatar of SubSun
SubSun
Flag of India image

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

SOLUTION
Avatar of piattnd
piattnd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bpl5000
bpl5000

ASKER

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?
Avatar of bpl5000

ASKER

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.
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

Avatar of bpl5000

ASKER

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?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you're running exchange, why not use the recipient policy to handle this.
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.
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).
Avatar of bpl5000

ASKER

These users are not Exchange users.
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.
Avatar of bpl5000

ASKER

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!
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.