In the current account creation script I am setting the following two attributes targetAddress and proxyAddressess:
$UserAttributes[0].Add('targetAddress', $User.mail)
$UserAttributes[0].Add('proxyAddresses', "SMTP:" + $User.mail)
I need to be able to change these values sometimes. I thought if I replaced add with replace that would work it did not.
Ideas?
Here is the whole function:
$AttributeItems=$UserAttributes[0].GetEnumerator()
ForEach ($AttributeItem in $AttributeItems) {
$AIKey=$AttributeItem.Key
$NewAttribute=$AttributeItem.Value
$ADAttribute=$FullUser.$AIKey
if ($ADAttribute -ne $NewAttribute) {
Set-ADUser $User.sAMAccountName -Replace @{$AIKey=$NewAttribute}
}
}
$UserAttributes[0].Add('targetAddress', $User.mail)
$UserAttributes[0].Add('proxyAddresses', "SMTP:" + $User.mail)
$ClearCount=$UserAttributes[1].Count
If ($UserAttributes[1].Count -gt 0) {
Set-ADUser $User.sAMAccountName -Clear $UserAttributes[1]
}
$enattendantgodot='Hold on there pardner!'