title: Find items which are in array1 but NOT in array2
body: <p>I extracted two lists of computers from two different tools, <code>Array1</code> and <code>Array2</code>.</p>
  
  <p>Now I need to extract the ones which are in <code>Array1</code>, but not in <code>Array2</code>.</p>
  
  <p>I managed to get all the matching ones by doing this:</p>
  
  <pre><code>$matchingComp = @()
  
  foreach ($SCCMcomputer in $SCCMcomputers) {
      foreach ($eWPTcomputer in $eWPTcomputers) {
          if ($SCCMcomputer.Computername -eq $eWPTComputer.Computername) {
              $obj = New-Object PSObject
              $obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $SCCMcomputer.Computername
              $matchingComp +=$obj
          }
      }
  }
  
  $matchingComp | Export-Csv $inEWPT -Delimiter "," -NoTypeInformation
  </code></pre>
  
  <p>But I still need the ones that are in <code>$SCCMcomputer</code> but NOT in <code>$eWPTcomputers</code>...</p>
  
  <p>I've found some solutions on SO with other languages (e.g. Perl) but not for PowerShell.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I still don't get the correct output, in Excel with this formula:</p>
  
  <p><a href="https://i.stack.imgur.com/Wv34V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wv34V.png" alt="enter image description here"></a></p>
  
  <p>the output looks like:</p>
  
  <p><a href="https://i.stack.imgur.com/x5gFZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x5gFZ.png" alt="enter image description here"></a></p>
  
  <p>means some are here, some not. The output in powershell is like this</p>
  
  <p><a href="https://i.stack.imgur.com/4b1Zg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4b1Zg.png" alt="enter image description here"></a></p>
  
  <p>means 0KB is emtpy.</p>
  
  <pre><code>$SCCMcomputers | Export-Csv $sccmexport -Delimiter "," -NoTypeInformation
  $eWPTcomputers | Export-Csv $ewptexport -Delimiter "," -NoTypeInformation
  Compare-Object -ReferenceObject $SCCMcomputers -DifferenceObject $eWPTcomputers | ?{$_.sideIndicator -eq "=&gt;"} |select inputobject | Export-Csv $inEWPT -NoTypeInformation
  Compare-Object -ReferenceObject $SCCMcomputers -DifferenceObject $eWPTcomputers | ?{$_.sideIndicator -eq "=="} |select inputobject | Export-Csv $inBoth -NoTypeInformation
  Compare-Object -ReferenceObject $SCCMcomputers -DifferenceObject $eWPTcomputers | ?{$_.sideIndicator -eq "&lt;="} |select inputobject | Export-Csv $inSCCM -NoTypeInformation
  </code></pre>
  
  <p>And both Column Name (or what it's called) from SCCMcomptuers/eWPTcomputers is "Computername"</p>
  
  <p>Any idea what I could be doing wrong? Both computer arrays are generated from SQL and in hashtables (I think it's called): <code>@{Computername=......}@{Computername....</code>, something like this.</p>
  
  <p><strong>Update 2</strong></p>
  
  <pre><code>foreach ($t in $sccmComputers) {
      $Test1 += $t.computername
  }
  
  $Test2 = @()
  foreach ($t in $ewptComputers) {
      $Test2 += $t.computername
  }
  </code></pre>
  
  <p>By removing the Header of the Hashtable and just having arrays full of strings works fantasctic..... even <code>-Property computername</code> did not work... :S</p>