title: Import-CSV and Foreach to use Get-ADUser
body: <p>I have a CSV file that looks like this:</p>
  
  <pre><code>name    
  fname1lname1@companyemail.com  
  fname2lname2@companyemail.com  
  ...
  </code></pre>
  
  <p>I would like to loop through each email address and query AD for that address to grab the user objects ID. I have been able to do this using a script, but I would like to be able to do it using just one line. </p>
  
  <p>This is what I've done so far:</p>
  
  <pre><code>import-csv -path .\csv_file.csv | foreach-object { get-aduser -filter { proxyaddresses -like "*$_.name*} | select name } | out-file .\results.csv
  </code></pre>
  
  <p>This obviously doesn't work and I know it has something to do with how I am handling my $_ object in the foreach loop. </p>
  
  <p>I'm hoping for the output to look something like:</p>
  
  <pre><code>fname1lname1@companyemail.com,userID1  
  fname2lname2@companyemail.com,userID2
  ...
  </code></pre>