title: Error handling a too long path in a foreach object loop in Powershell
body: <p>I currently have this:</p>
  
  <pre><code>Get-ChildItem $somelongpath -Recurse -ErrorVariable MyError -ErrorAction Stop  | where {$_.PSIsContainer} | ForEach-Object{
       if($MyError){
          Write-Host "Don't do it"
       } else {
          Write-Host "Yay!"
       }
  }
  </code></pre>
  
  <p>Say that <code>$somelongpath</code> is a path that exceeds the 260 limit and therefore get-childitem should receive an error and print "Don't do it". But it doesn't... What is happening?</p>