powershell - Getting error after using ErrorAction Silentlcontinue in my command -
i still getting error in out after using -erroraction silentcontinue
. here command using:
get-childitem c:\ -include *.bak -recurse | foreach ($_) {remove-item $_.fullname } -erroraction silentlycontinue -errorvariable
you retrieve error within get-childitem
cmdlet. should add parameter there (-ea 0
alias -erroraction silentlycontinue
).
also usage of foreach-object
cmdlet within code obsolete since remove-item
cmdlet takes pipeline object:
get-childitem c:\ -include *.bak -recurse -ea 0 | remove-item -ea 0
Comments
Post a Comment