title: Update Active Directory "mail" attribute via PowerShell
body: <p>I'm trying to update the email address listed in AD for all the users in a particular OU. This is the powershell script I'm using, but it's not working properly</p>
  
  <pre><code>Import-Module ActiveDirectory
  Get-ADUser -Filter * -SearchBase "OU=OtherOU,OU=SomeOu,DC=Domain,DC=local" | Set-ADUser -email $_.samaccountname@domain.com
  </code></pre>
  
  <p>I think it's because $_.samaccountname isn't returning anything when I try to do Set-ADUser.
  Can anyone point me in the right direction for fixing this? Thanks!</p>