Changing ProxyAdress field values

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 5 months ago.

  • Author
    Posts
  • #6224

    by hunterz at 2012-12-06 03:57:53

    Hi!

    I am not expert in powershell, so asking for some help here!
    I have such case.

    Current situation]
    I need to change ProxyAdress values in AD 2008 for users who have them (not all users have them, ones without proxyAdress dont need any changes). Atm users have 1 e-mail adress in proxyAdress field "SMTP:name.surname@olddomain.com"

    Need to achieve]
    "SMTP:name.surname@newdomain.com"
    "smtp:name.surname@olddomain.com"
    So newdomain.com adress must become primary adress, in meantime keeping olddomain.com as secondary adress

    Posible problems]
    Its not my own created domain, e-mails never was on Exchange, they had Lotus backdays and i am not sure about exact match beatwean e-mails name.surname with AD field values GivenName and sn.
    So from my point of understanding safest way to avoid any problems with this would be:
    change olddomain.com to newdomain.com in ProxyAdress field (to keep it as primary e-mail adress) and then add new record "smtp:name.surname@olddomain.com", by taking name.surname part from ProxyAdress field.

    Could any powershell expert can help me to achieve this goal?

    by kittH at 2012-12-06 06:56:49

    There are a few ways to do it, but we need to be careful we don't overwrite the wrong information.
    Do the users have any other information in the proxyaddresses field? Do any of the users have multiple SMTP addresses that will need to be accounted for?

    Here is one attempt, but please test thoroughly before removing the whatif, as it may have unexpected effects if you have other types of domain addresses in there (SIP for example)

    Foreach ($User in (Get-QADUser)){
    If($User.ProxyAddresses){
    $OldSMTP = $User.ProxyAddresses | Select-String "SMTP" | Select -ExpandProperty Line
    $Proxy = $User.ProxyAddresses.Replace("OldDomain.com", "NewDomain.com")
    $Proxy += $OldSMTP
    Set-QADUser $User -ObjectAttributes @{ProxyAddresses=$Proxy}}}

    by hunterz at 2012-12-07 02:46:31

    Thanks for script!!! Will test it carefully. No, atm users have only 1 value in proxyAddress, multivalues. And there are no other information, except one listed above. So no things to worry about. 🙂

You must be logged in to reply to this topic.