Trap remove-item exception Trap remove-item exception powershell powershell

Trap remove-item exception


The trap will only trigger on a terminating error.

  rm "$($_.Name).old" -ErrorAction "Stop"