title: powershell change AD user attribute
body: <p>I need to search through all users in AD, find their attribute "mail" and in this attribute replace @hell.com to @heaven.com</p>
  
  <p>I'm stuck at exporting and importing to csv...</p>
  
  <pre><code>Import-Module ActiveDirectory
  get-aduser -Filter {samaccountname -like "gmaleev"} -properties * | Select-Object SamAccountName,mail | export-csv -NoTypeInformation d:\1.csv
  $impfile = "d:\1.csv"
  Import-CSV $impFile
  foreach ($user in $users)
  {
  $sam = $user.samaccountname
  $email = $user.mail
  write-host "User $sam has mail $mail"
  }
  </code></pre>
  
  <p>It doesn't work, why?</p>