title: Trying to add employee numbers to Active Directory
body: <p>I am tryign to add employee numbers to all of my AD users by importing a csv file with first name, last name, employee number and email fields.</p>
  
  <p>The issue I am having is that I have come across some users that the first name in the csv file does not match up to the first name in AD.</p>
  
  <p>I have searched for weeks on trying to figure out how to get powershell to search ad using the last name and only the first letter of the first name field from the csv, but I juat cannot figure it out.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Here is my script:</p>
  
  <pre><code>Import-Module ActiveDirectory
  ForEach ($User in (Import-CSV -Path 'C:\Users\mike.mullen\Desktop\Active Users with Email.csv'))
  {
  $Last = $User.LastName
  $First = $User.FirstName
  $EmployeeNumber = $User.EmployeeId
  Get-ADUser -Filter '(Surname -eq $Last) -and (GivenName -like $First)' |
  Set-ADObject -Replace @{EmployeeNumber="$EmployeeNumber"}
  }
  </code></pre>