In this guide, you will learn how to add proxyaddresses in Active Directory with PowerShell and the AD Pro Toolkit. I’ll also show you how to remove proxyAddresses with PowerShell. Bulk updating the proxyaddresses attribute is often required when migrating to Office 365, creating new accounts, adding a new domain, and so on.
I recommend testing this with a few accounts to make sure the proxyAddresses update as needed. After verifying the accounts update correctly, then proceed with bulk update user accounts.
Add ProxyAddresses Using PowerShell
In this example, I’ll use set-aduser command to add a proxy address to a user account
Open PowerShell:
Copy and paste the script below:
Set-ADUser Adrienne.Williams -add @{ProxyAddresses="smtp:adrienne.williams.mail.onmicrosoft.com"}
Get ProxyAddresses:
Use this command to view the ProxyAddresses for a user.
get-aduser adrienne.williams -Properties ProxyAddresses | select Name, ProxyAddresses"}
Bulk add proxyaddress with PowerShell:
Use this command to add multiple proxyaddress.
Set-ADUser Adrienne.Williams -add @{ProxyAddresses="smtp:adrienne.williams.mail.onmicrosoft.com,SMTP:adrienne.williams.mail.onmicrosoft.com" -split ","}
Option#2 Bulk User Updater Tool
In this example, I’ll use the AD Pro Toolkit to add proxyaddreses to multiple users. This tool makes it easy to mass update user attributes.
Step 1. Download the CSV Template
Step 2. Add proxy addresses to the template
To add multiple proxy addresses separate them with a comma.
Step 3. Choose Options
Step 3. Select your template and click run.
Download Free TrialBulk Add, Update, or Remove ProxyAddresses with AD Pro Toolkit
With the AD Pro Toolkit, you can easily perform bulk updates on the ProxyAddresses attribute.
Enter the user and proxyaddresses into the template.
Select from the two options.
- Add New = This will add new proxyAddresses
- Update Existing = This will modify a users existing proxyAddress. Use the proxyAddress_update column in the CSV template for this option.
Select your CSV file and click run.
How to Replace ProxyAddresses using PowerShell
You can use the -replace parameter to replace the user’s current ProxyAddress value.
Warning: Using the -replace parameter will replace all addresses with the values you provide.
Let’s list the user’s current addresses
get-aduser adrienne.williams -Properties ProxyAddresses | select Name, ProxyAddresses
So this user has two addresses listed. I’m going to pretend these addresses are wrong or no longer needed and replace them all.
Use this command to replace the ProxyAddresses.
Set-ADUser Adrienne.Williams -replace @{ProxyAddresses="SMTP:adrienne.williams.activedirectorypro.com"}
Now I’ll check the account.
You can see the -replace command cleared out both addresses and replaced it with the single address.
If you want to replace the value with multiple address use this command.
Set-ADUser Adrienne.Williams -replace @{ProxyAddresses="SMTP:adrienne.williams.activedirectorypro.com,SMTP:adrienne.williams.ad.com" -split ","}
How to Remove ProxyAddresses using PowerShell
You can use the -remove parameter to remove single or multiple addresses.
Remove single address.
Set-ADUser Adrienne.Williams -remove @{ProxyAddresses="SMTP:adrienne.williams.activedirectorypro.com"}
Remove multiple addresses.
Set-ADUser Adrienne.Williams -remove @{ProxyAddresses="SMTP:adrienne.williams.activedirectorypro.com,SMTP:adrienne.williams.ad.com" -split ","}
Bulk Add ProxyAddress for Multiple Accounts using PowerShell
To update multiple user accounts you will need to set up a CSV file with a samaccountname column and proxyaddresses column.
Enter as many proxyaddresses as you need and separate them by a comma.
Here is an example of a CSV file.
For this example, I’m going to update all the users in the Administrations organizational unit. To list all the users current addresses in an OU run the command below. You will need to change the value of the -SearchBase to the distinguished name of the OU.
get-aduser -filter * -SearchBase "OU=Administrations,OU=ADPRO Users,DC=ad,DC=activedirectorypro,DC=com" -Properties ProxyAddresses | select Name, ProxyAddresses
You can see two users have proxyaddresses and the rest do not.
To update these accounts with the information in the CSV file, use the command below. You will need to update the path to your CSV file.
Import-Csv "C:\it\bulk-proxy2.csv" | foreach {Set-ADUser -Identity $_.samaccountname -add @{Proxyaddresses=$_.Proxyaddresses -split ","}}
Now I’ll check the values if they have been updated.
Great!
It looks like all the accounts in the Administrations OU have been updated from the CSV file.
Summary
If you are using Azure AD connect or Office 365 then knowing how to bulk update users ProxyAddresses attribute is a must. In this guide, I showed you multiple examples for updating single accounts, adding multiple addresses, and bulk updating a list of accounts from a CSV file
PowerShell is a great tool for making mass changes to Active Directory users but for those that want a GUI option, the AD Bulk User Update tool is a simple and easy solution.
Let me know in the comments below if you have any questions.
Hi Robert,
This tutorial is only for on-premise, right?
Is there a way to remove an address in “ProxyAddresses” for the Azure AD PowerShell module? I have the feeling it is locked and only modified in license updates.
The user does not have a license (and therefore no mailbox) so the Exchange Online Powershell module is not an option.
I could just add a license to the user and then change the E-Mail aliases in the EAC but then it would still be billed after I revoke the license?
Yes, this tutorial is for on-premise.
This was very useful, i need to readdress many proxy addresses as part of an acquisition and using EAP is not going to work.
What i noticed was that i ended up with two Primary SMTP addresses, so need to figure a way to overwrite the original primary SMTP.
With the GUI tool, you can use the remove option to remove all the proxy addresses then add them back with only the addresses needed. I’ve had several customers use this method.
Hi guys
if you want to insert multiple addresses in proxyadresses field , I modified the code and the csv like this:
csv:
samaccountname&Proxyaddresses&Proxyaddresses2&Proxyaddresses3
use1r&smtp:user1_email@domain.com&SMTP:user2_email_primary_email@domain.com&smtp:anotheralias_email@domain.com
code:
Import-Csv “C:\temp\deploy.csv” -Delimiter “&” | foreach {Set-ADUser -Identity $_.samaccountname -add @{Proxyaddresses=$_.Proxyaddresses -split “&”}
Set-ADUser -Identity $_.samaccountname -add @{Proxyaddresses=$_.Proxyaddresses2 -split “&”}
Set-ADUser -Identity $_.samaccountname -add @{Proxyaddresses=$_.Proxyaddresses3 -split “&”}}
with this , the code enter for each user 3 times to put the diferents proxyaddresses..
I hope someone will find it useful!
Thanks for this cool manual, but i run into different issues…
the most i was able to solve but one is pretty hard…
if i have multiple smtp adrresses for example: smtp:user1@ms.com,user01@ms.com
it will only set the first e-mail address but not all the others….
any idea how i could fix this?
thanks and regards
Not sure if you got this figured out but I would say that the second one is a violation because it doesnt have a proxy type. In this example we user SMTP then we separate the Proxy type from the address. So you can have many others SIP, X500, SMTP etc. So change your code to be smtp:user1@ms.com,SMTP:user01@ms.com.
Hello,
I’ve find what is the issue with the error “Cannot validate argument on parameter ‘Identity’. The argument is null.”
you must create a CSV with the comma “,” separator not “;”
and then change the comma separator between each smtp address by another character instead of “,” in my case I’ve used the character “&”, and then the command worked well.
So here is the command line: Import-Csv “C:\it\bulk-proxy2.csv” | foreach {Set-ADUser -Identity $_.samaccountname -add @{Proxyaddresses=$_.Proxyaddresses -split “&”}}
Hello, it states that you can remove proxy addresses by adding the word remove. I’ve tried updating, but it doesn’t seem to remove the proxy addresses. Do you have the syntax?
Are you getting an error?
Here is the link to Microsofts documentation and syntax
https://docs.microsoft.com/en-us/powershell/module/addsadministration/set-aduser?view=win10-ps
If i run manual PS … \users.csv” | foreach {Set-ADUser -Identity $_.samaccountname -add @{ …
it is successful in adding the proxyaddresses from the csv
When i use the ADBulkUserUpdate tool it removes all existing addresses and puts the csv proxyaddresses as a single entry when i use the same csv
I’ve updated the tool to append the proxyaddresses instead of removing and putting only what’s in the CSV. If you need to remove values you can add the word remove to the csv.
Planning to do a bulk roll out of 300 users. Can I update the spreadsheet and add a “mail” attribute? The email address isn’t using the same UPN suffix as the login domain so I would like to add the emails that will be used.
Sure you can modify the script and spreadsheet to add whatever you need.
Purchased your tool, but it doesn’t work. I have created the CSV exactly like you propose, and the tool can read the attributes in the file – but when I run it, I’m just told that it cannot update the attributes.
Why?
Hi Michael,
I sent you an updated version. Try it out and let me know if you still have issues.
Hi Robert, Can I get the updated version of user export / bulk update ? I need to update proxyAddresses .
Yup, I sent you a link.
Hi Robert. Can you please send me the link as well?
Hi Jhon,
What link?
Bulk update using CSV file fails. It seems parameter ‘Identity’ is missing:
“Set-ADUser : Cannot validate argument on parameter ‘Identity’. The argument is null.”
Very useful article. Thank you!
Hi!
When I use the command:
Import-Csv “C:\Temp\users.csv” | foreach {Set-ADUser -Identity $_.samaccountname -add @{Proxyaddresses=$_.Proxyaddresses -split “,”}}
I got the following error:
Set-ADUser : Cannot validate argument on parameter ‘Identity’. The argument is null. Provide a valid value for the
argument, and then try running the command again.
At line:1 char:64
+ … \users.csv” | foreach {Set-ADUser -Identity $_.samaccountname -add @{ …
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-ADUser], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.SetADUser
The csv file is prepared in the same way you described above. What am I doing wrong?
Looks like I have a type in my CSV. Change the CSV header from samacountname to samaccountname.
I get the exact same error.
Try to add -delimiter paramenter in import-csv:
Import-Csv “C:\temp\proxy_update_test0.csv” –Delimiter “;” | foreach-object….
seems to solve problem
Cheers
Merlinweb
The above multiple is not working with either the script or GUI Tool, script adds the value “Microsoft.ActiveDirectory.Manamgement.ADPropertyValueCollection”, GUI Tool adds all values on the same line.
When did you download the GUI tool? I recently updated it to fix the issue of putting the values on the same line. If you log in you can download the latest version.