Solved

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

Posted on 2010-08-22
5
2,431 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
5 Comments
 
LVL 12

Expert Comment

by:Rant32
Comment Utility
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
Comment Utility
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
Comment Utility

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
Comment Utility
@jimmyray - obviously you missed the whole Powershell part of my question. Read it again.
0
 
LVL 13

Accepted Solution

by:
soostibi earned 300 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now