title: get displayname and office from samaccountname export to csv
body: <p>How I can get the <code>displayname</code> and the office from a <code>samaccountname</code> list (.txt)? After that I want to save the <code>displaynames</code> and the offices to a .csv file. Here is a approach: </p>
  
  <pre><code>$users = Get-Content C:\TMP\test.txt
  foreach ($user in $users)
  {
      Get-ADUser -ldapfilter "(samaccountname=$user)" -Property name, office | Select-Object -Property Name, Office
  
  } 
  </code></pre>
  
  <p>It should look like: </p>
  
  <p><img src="https://i.stack.imgur.com/NmF1l.png" alt="enter image description here"></p>
  
  <p>Hope you can help me?</p>