title: Powershell fastest way to merge two arrays using a common property?
body: <p>What's the fastest way to merge two arrays using a common property?</p>
  
  <pre><code>Users | Select *
  Username : Joe.Doe
  Office   : Chicago
  Email    :
  
  Username : Mike.Smith
  Office   : New York
  Email    :
  ...
  </code></pre>
  
  <pre><code>UserEmails | Select *
  AccountEmail  : Mike.Smith
  EmailAddress  : mike-smith@example.com
  
  AccountEmail  : Joe.Doe
  EmailAddress  : jsmith12@example.com
  ...
  
  </code></pre>
  
  <p>The merge should result in:</p>
  
  <pre><code>UsersCompleteList | Select *
  Username : Joe.Doe
  Office   : Chicago
  Email    : jsmith12@example.com
  
  Username : Mike.Smith
  Office   : New York
  Email    : mike-smith@example.com
  ...
  </code></pre>
  
  <p>Something like <code>for each ($user in $users) { ($user.Email = $userEmails | ? { $_.AccountEmail -eq $user.Username}).EmailAddress</code> takes ages on large datasets.</p>