title: Powershell create new array by subtracting from the original array
body: <p>I have a large data array (Invoke-Sqlcmd export, array variable), lets say it contains all of our 'customers'.
  I have large data list (Local search results, string variable), lets say it contains all of our 'paying customers'
  I want to create a final array by subtracting the people in the list from the array, leaving me with 'customers who have not paid yet'. The code is doing exactly this but runs very slow, Im hoping to educate myeself on a quicker way.</p>
  <p>The size of the first array is around 25,000 and the size of the list is around 20,000. Because the list is just a plain text variable, I first split it on new lines to allow the ForEach to take place (otherwise it registers as one object) The code im using to do this is:</p>
  <pre><code>$NewArray = $FirstArray
  
  ForEach ($Customer In $List)
  {
  $NewArray = $NewArray | ? {$_.CustomerID -ne $Customer}
  }
  </code></pre>
  <p>any help greatly appreciated, Thanks</p>