AntiMalware Status

Add SMTP-ProxyAddress to users in AD with PowerShell

Here is a quick way to add new SMTP/ProxyAddress for the users in Active Directory with use of PowerShell.

Create a csv file with two columns
samaccountname | emailaddress
john.doe                 |

First column has user samaccountname and second column make sure you use the format; “

Once you have the csv file ready you can run this PowerShell script to update all those users with new SMTP/ProxyAddress.

Import-module ActiveDirectory
Import-Csv .\SMTPLIST.csv | ForEach-Object
$username = $_.samaccountname
$userproxy = $_.emailaddress -split ';'
Set-ADUser -Identity $username -Add @{proxyAddresses= $userproxy}

To see proxy address for the user:

Get-ADUser john.doe -Properties ProxyAddresses | select Name, ProxyAddresses

To set the user with a Proxy address:

Set-ADUser John.Doe -add @{ProxyAddresses=""}

Also you can add multiple Proxy address in PowerShell command line:

Set-ADUser John.Doe -add @{ProxyAddresses="," -split ","}

In case you wish remove the proxy address from user:

Set-ADUser John.Doe -remove @{ProxyAddresses=""}

Remove multiple Proxy addresses from user:

Set-ADUser John.Doe -remove @{ProxyAddresses="," -split ","}

All done!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.