我目前有这个:
Get-ChildItem $somelongpath -Recurse -ErrorVariable MyError -ErrorAction Stop | where {$_.PSIsContainer} | ForEach-Object{
if($MyError){
Write-Host "Don't do it"
} else {
Write-Host "Yay!"
}
}
假设$somelongpath
是超过260限制的路径,因此get-childitem应该收到错误并打印"不要这样做"。但它没有...发生了什么?