title: Proxyaddresses added to the multivalued attribute not appearing on seperate lines
body: <p>I am using the following script to create a spreadsheet of users and proxyaddress values (matching a string) as a record prior to removing them, in the case of an emergency I want to be able to put the values back.  </p>
  
  <p>The script works well if there is only a single entry per user, the issue is seen when a user has more than one entry.  The problem is that when I attempt to revert back to the original values, when viewed through an attribute editor the proxyaddresses are appearing all on one line instead of a separate line for each proxy address.  I am not sure if the fault is on the collection script, or the script I am using to set the values.  To collect the values I am running the following:</p>
  
  <pre><code>$entry = "*test.com"
  $users = get-content "Testusers.txt"
  $date = get-date
  $mydata = @()
  $domain = [system.environment]::UserDomainName 
  $attribute = "Proxyaddresses"
  $report = "{0}_{1}_{2:HHmm_dd-MM-yyyy}.txt" -f $attribute,$domain,$date
  $px = $users | Get-ADUser -Properties proxyaddresses -server $domain
  
  foreach ($user in $px){
  if ($user.proxyaddresses -like $entry){
      $name = $user.samaccountname
      $proxyaddresses = $user.proxyaddresses -like $entry
      $mydata += New-Object PSObject -Property @{
          Samaccountname = $name
          Proxyaddresses = $proxyaddresses
      }
    }
  }
  $mydata | select samaccountname,@{ l = "Proxyaddresses"; e = {$_.Proxyaddresses } }| export-csv "$PWD\$report" -NoTypeInformation -Append
  </code></pre>
  
  <p>To return the values back to the original state I am running the following:</p>
  
  <pre><code>$csv = import-csv "Proxyaddresses_Domain_1201_05-04-2017.csv"
  $domain = [system.environment]::UserDomainName 
  $attribute = "Proxyaddresses"
  foreach ($line in $csv){
  $user = $line.samaccountname
  $proxyaddresses = $line.proxyaddresses
  Get-aduser $User -server $domain -Properties $attribute | Set-ADUser -add 
  @{$attribute = $proxyaddresses} -server $domain
  }
  </code></pre>
  
  <p>I have tried various things such as in the collection script</p>
  
  <pre><code>$proxyaddresses = $line.proxyaddresses -join ","
  </code></pre>
  
  <p>I have also tried the same tactic in the script used to set the values but instead of creating a new line it removes a space between the entries on the same line when viewed through an AD attribute editor.</p>
  
  <p>I have also tried to change</p>
  
  <pre><code>$proxyaddresses = $user.proxyaddresses -like $entry 
  </code></pre>
  
  <p>to the following however this did not solve the problem</p>
  
  <pre><code>$proxyaddresses = ([Microsoft.ActiveDirectory.Management.ADPropertyValueCollection]$user.proxyaddresses -like $entry
  </code></pre>
  
  <p>HELP!!!</p>