title: Powershell filter a list of names
body: <p>Heyho, for a little script I'm making I have a huge list of users that I get from the active directory,
  for example by:</p>
  <pre><code>$userlist = Get-ADUser -Filter *
  </code></pre>
  <p>I've already narrowed it down to the search only the folder that I want it to search.. but there are still some &quot;corpses&quot; in there, some dead accounts that don't need to be in the list, but that also can't be deleted from the domain. How can I filter these accounts out of the list?
  Here are the fields that each user has in my list:
  <a href="https://i.stack.imgur.com/ABgG8.png" rel="nofollow noreferrer">screenshot</a> of the output from Get-ADUser</p>
  <p>If possible I'd like to filter out a list of names that are in another text file that I put into a variable. (I'd like to filter it by the &quot;Name&quot; field)</p>
  <p>I've tried things along the line of:</p>
  <pre><code>$userlist = Get-AdUser -Filter 'Name -notin $Filter'
  </code></pre>
  <p>but that doesn't seem to work :(
  I managed to do it with a single keyword, but can't get it done with a list</p>
  <pre><code>$userlist = Get-ADUser -Filter 'Name -notlike &quot;*test*&quot;'
  </code></pre>
  <p>Thanks for the help!</p>