Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to add additional SMTP address and make it the primary SMTP address

Posted on 2010-08-22
5
Medium Priority
?
2,497 Views
Last Modified: 2013-12-24
I'm trying to add or in some cases just change the primary SMTP (format= samaccountname@domain.com) for certain mailboxes. I have a file that has these mailboxes. The script that I'm including here works; it adds the SMTP address in the format that I want and makes it the primary SMTP. However, it wipes all the other SMTP addresses; I don't want to wipe anything. I simply want to add/change the primary SMTP while leaving all other SMTP accounts intact.
# source TXT file contains SAMACCOUNTNAMES
$users = Get-Content -Path 'C:\users.txt'

foreach($user in $users){

	Set-QADUser -Identity $user -IncludedProperties proxyAddresses -ObjectAttributes @{proxyAddresses="SMTP:"+$user+"@domain.com"}
	
	}

Open in new window

0
Comment
Question by:bndit
[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
5 Comments
 
LVL 12

Expert Comment

by:Rant32
ID: 33497929
Manually setting the SMTP proxy addresses may get your changes overwritten by the Email Address Policy.

You need a higher-priority EAP to set a new Reply address. Set up the recipients and Conditions such that only these users are affected by the EAP.
0
 
LVL 2

Author Comment

by:bndit
ID: 33497950
Thx for the feedback. I'll definitely look into the policy. But for the sake of this answer, I would still like to know how to add the smtp address.
0
 
LVL 8

Expert Comment

by:jimmyray7
ID: 33498232

Open AD users and computers. select the user and view properties.

Select the email addresses tab, click add, select SMTP address, type the new email and hit okay.

Select the new address and click 'set as primary'.

All set!
0
 
LVL 2

Author Comment

by:bndit
ID: 33498327
@jimmyray - obviously you missed the whole Powershell part of my question. Read it again.
0
 
LVL 13

Accepted Solution

by:
soostibi earned 1200 total points
ID: 33498907
Try this:
# source TXT file contains SAMACCOUNTNAMES  
$users = Get-Content -Path 'C:\users.txt'  
  
foreach($user in $users){  
        $addresses = (Get-QADUser $user -IncludedProperties proxyaddresses).proxyaddresses | 
            %{if($_ -ilike "SMTP:*"){$_ -replace "SMTP:","smtp:"}else{$_}}
        $addresses = @($addresses) + "SMTP:$user@domain.com"
        Set-QADUser -Identity $user -ObjectAttributes @{
                EmailAddressPolicyEnabled = $false; 
                proxyAddresses=$addresses
              }  
        }

Open in new window

0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

609 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