title: import-csv, get-aduser, then export-csv to filter out non-existing AD users
body: <pre><code>Import-Csv C:\username.csv | 
  ForEach-Object (Get-ADUser $_.Username -Properties displayname | 
  Export-Csv C:\usernames.csv
  </code></pre>
  
  <p>I have an old fileserver (2k3) with a bunch of homefolders.  I exported a csv with <code>get-childitem</code> for the directories.  I was going to use the name of the folder, which is mirrored to the AD username, to query AD with <code>Get-ADUser</code>.  If AD user does not exist, then filter out those non existing users and <code>export-csv</code> the "active" ad users. The exported CSV would then be used in my script to migrate "active" homefolders to new homefolder VM.  I have used the above code unsuccessfully.  Any input would be helpful.</p>