title: Importing email addresses into Active Directory
body: <p>I'm trying to import a CSV file that will update users in our AD environment with their proper email addresses. </p>
  
  <p>The first few lines of the CSV look like this:</p>
  
  <pre><code>Email,Name
  adam.lambert@domain.com,Adam Lambert
  aaron.smith@domain.com,Aaron Smith
  arthur.aardvark@domain.com,Arthur Aardvark
  </code></pre>
  
  <p>The PowerShell script I've written looks like this:</p>
  
  <pre><code>Import-Module ActiveDirectory
  $data = Import-CSV -Path "C:\Users\redacted\Desktop\importtest.csv"
  Foreach ($user in $data){
  Get-ADUser -Filter “Name -eq ‘$($user.Name)'” | Set-ADUser -Replace @{mail = “$($user.Email)”}
  }
  </code></pre>
  
  <p>However, much to my dismay, it doesn't work. To clarify, I am trying to match the ADSI value of "name" (not the SamAccountName) with the list in Excel, which I know for a fact are exact matches.</p>
  
  <p>Any thoughts? Error is below:</p>
  
  <pre><code>Get-ADUser : Error parsing query: 'Name -eq ‘Adam Lambert'' Error Message: 'syntax error' at position: '10'.
  At line:4 char:11
  + Get-ADUser &lt;&lt;&lt;&lt;  -Filter “Name -eq ‘$($user.Name)'” | Set-ADUser -Replace @{mail = “$($user.Email)”}
      + CategoryInfo          : ParserError: (:) [Get-ADUser], ADFilterParsingException
      + FullyQualifiedErrorId : Error parsing query: 'Name -eq ‘Adam Lambert'' Error Message: 'syntax error' at position: '10'. 
     ,Microsoft.ActiveDirectory.Management.Commands.GetADUser
  </code></pre>