title: Can the following Nested foreach loop be simplified in PowerShell?
body: <p>I have created a script that loops through an array and excludes any variables that are found within a second array.</p>
  
  <p>While the code works; it got me wondering if it could be simplified or piped.</p>
  
  <pre class="lang-bsh prettyprint-override"><code>   $result = @()
     $ItemArray = @("a","b","c","d")
     $exclusionArray = @("b","c")
  
      foreach ($Item in $ItemArray)
      {
          $matchFailover = $false
          :gohere
          foreach ($ExclusionItem in $exclusionArray)
          {
              if ($Item -eq $ExclusionItem)
              {
                  Write-Host "Match: $Item = $ExclusionItem"
                  $matchFailover = $true
                  break :gohere
              }
              else{
              Write-Host "No Match: $Item != $ExclusionItem"
              }
          }
          if (!($matchFailover))
          {
              Write-Host "Adding $Item to results"
              $result += $Item
          }
      }
      Write-Host "`nResults are"
      $result
  </code></pre>