Modifying Multivalued Attributes With PowerShell

[int] $ADS_PROPERTY_CLEAR = 1;
[int] $ADS_PROPERTY_UPDATE = 2;
[int] $ADS_PROPERTY_APPEND = 3;
[int] $ADS_PROPERTY_DELETE = 4;

# Get the user's Distinguished Name (DN) however you prefer.
# Utilize the above option switch to adjust.
$ADuser = [ADSI]"LDAP://SERVER-NAME-HERE/$($theUserAccount.DistinguishedName)"          
$ADuser.PutEx($ADS_PROPERTY_DELETE, "proxyAddresses", @("smtp:$userNameForUpdate@contoso.com"))
$ADuser.PutEx($ADS_PROPERTY_APPEND, "proxyAddresses", @("SMTP:$userNameForUpdate@extranet.contoso.com"))

# Commit the changes to the AD User Object:
$ADuser.SetInfo()

Reference:
http://technet.microsoft.com/en-us/library/ee156515.aspx

Advertisements