FMeinicke's Wiki

Home

❯

Windows

❯

Powershell

❯

Don't fail if removing non existent items

Don't fail if removing non-existent items

May 27, 20251 min read

  • pwsh/remove-item
  • pwsh/-error-action

remove-item -error-action

Source

  • https://stackoverflow.com/a/63157816/12780516
  • use -ErrorAction Ignore (return code will be success), or -ErrorAction SilentlyContinue (return code will be failure, but not error be raised)
Remove-Item <Path> -ErrorAction Ignore

Graph View

Created with Quartz v4.5.0 © 2025

  • GitHub