title: Change email address in CSV
body: <p>I am writing PowerShell code to export email addresses to a csv file and edit them. I've written the following:</p>
  
  <pre><code># Script to get all DLs and email addresses in csv file
  Get-ADGroup -Filter 'groupcategory -eq "distribution"' -Properties * |
      select Name, mail |
      Export-csv "C:\temp\Distribution-Group-Members.csv"
  
  # Following will import the csv, make new column as proxy and save the file
  # as update.csv 
  Import-Csv "C:\temp\Distribution-Group-Members.csv" |
      Select-Object "Name", "mail", @{n = "proxy"; e = "mail"} |
      Export-Csv "c:\temp\Distribution-Group-Members-Updated.csv" -NoTypeInfo
  
  # Following script can import the csv and set proxy addresses from proxy
  # column 
  Import-Csv "c:\temp\Distribution-Group-Members-Updated.csv" |
      Foreach {
          Get-ADGroup $_.Name | Set-ADGroup -Add @{
              proxyaddresses = ($_.proxy -split ";")
          }
     }
  </code></pre>
  
  <p>Now, I would like to add 2 more features in the script:</p>
  
  <ul>
  <li>update domain for existing mail column e.g. update mail address form test@abc.com to test@xyz.com </li>
  <li>Add SMTP:test@xyz.com;smtp:test@abc.com" as Proxy mail address, so that xyz become primary mail address and abc as proxy domain</li>
  </ul>
  
  <p>So assuming my DL name is "DL Test" email is "test@abc.com" => The script should update the email address of DL to "test@xyz.com" and add "smtp:test@abc.com" as proxy mail address</p>
  
  <p>Can someone please advise, how can I achieve that?</p>