Reputation: 61
I am still getting error in my out after using -Erroraction Silentcontinue
. Here is my command I am using:
get-childitem c:\ -include *.bak -recurse | foreach ($_) {remove-item $_.fullname } -ErrorAction SilentlyContinue -ErrorVariable a
Upvotes: 2
Views: 104
Reputation: 58991
You probably retrieve the error within the Get-ChildItem
cmdlet. So you should add the parameter there too (-ea 0
is the alias for -ErrorAction SilentlyContinue
).
Also the usage of the Foreach-Object
cmdlet within your code is obsolete since the Remove-Item
cmdlet takes a pipeline object:
Get-ChildItem c:\ -include *.bak -recurse -ea 0 | Remove-Item -ea 0
Upvotes: 4