title: Remove Object from Arraylist Powershell
body: <p>I want to delete objects inside of a Arraylist. Since I'm new to Powershell I found myself in quite a bit of trouble.</p>
  <p>More Specifically I want to delete Objects inside of the first Arraylist and if the object is the same as in the second Arraylist it should get removed.</p>
  <p>Here is what I tried so far. As a reference I tried to use this page: <a href="https://www.sapien.com/blog/2014/11/18/removing-objects-from-arrays-in-powershell/" rel="nofollow noreferrer">https://www.sapien.com/blog/2014/11/18/removing-objects-from-arrays-in-powershell/</a></p>
  <pre><code>[System.Collections.ArrayList]$everyExistingFolder = (Get-ChildItem -Path &quot;$PSScriptRoot\test&quot; | foreach { $_.Name })
  
  [System.Collections.ArrayList]$everyFolderWichShouldExist = (Get-Content &quot;$PSScriptRoot\directoriesADExport.txt&quot;)
  
  
  
  
  
  $output = ForEach ($element in $everyExistingFolder)
  {
     if($element -eq $everyFolderWichShouldExist){
     
     $everyExistingFolder.Remove($element)
     
     }
     
  }
  
  
   Out-File $output
  </code></pre>
  <p>Is something as this possible, or did I try the wrong solution.</p>
  <p>Would love to hear any tips or advice.</p>