Can PowerShell trap errors in GetChildItem and continue looping?
have you used silentlycontinue?
foreach($file in Get-ChildItem $dirRoot -Recurse -ErrorAction silentlycontinue) {
...
}
How about Inquire?
foreach($file in Get-ChildItem $dirRoot -Recurse -ErrorAction Inquire) {
...
}
Maybe open up a second PS window to troubleshoot the error then continue the command in the first PS window by selecting Y for continue.
You can also use ErrorVariable
foreach($file in Get-ChildItem $dirRoot -Recurse -ErrorVariable a) {
...
}
Get-Variable a or $a will show you all the errors incurred by the command. You can also use +variablename (+a) to add errors to an existing variable.
foreach($file in Get-ChildItem $dirRoot -Recurse -ErrorVariable +a) {
...
}