changing ProxyAddresses and adding two similar entries, with LOWER and UPPER cases 'smtp' and 'SMTP'
foreach($user in (Get-ADUser -Filter {SamAccountName -like 'USERPRXY*' -and enabled -eq $TRUE} )) { Set-ADUser $($user.SamAccountName) -Add @{'ProxyAddresses'="smtp:$($user.samaccountname)@MyCorp.Net"} }
i´m running this piece of code and work flawlessly.... well, almost there
due to internal requirements, we´ll need to add "smtp" and ALSO "SMTP", two entries
in this particular line of code, running twice, with the same code, another entry is not added, ok, no problem, but when i change the code from smtp to SMTP (upper), hoping to add a second entry in upper case... does not work, the previous lower case entry remains and no upper case is added either
adding the WHATIF:
What if: Performing the operation "Set" on target "CN=USERPRXY1,CN=Users,DC=MyCorp,DC=Net".
What if: Performing the operation "Set" on target "CN=USERPRXY2,CN=Users,DC=MyCorp,DC=Net".
tried:
-Add @{'ProxyAddresses'="SMTP:"+$($user.samaccountname)+"@MyCorp.Net"
no luck!
But i noticed:
Using smtp:".toupper()+$($user.samaccountname) work,s but ONLY IF I DELETE the contents of the field, leaving the Proxyaddress BLANK, if i already have something in, don´t work