PowerShell – Delete Files
Note: This is a recovered post from my old blog. See how we recovered these posts using the Wayback Machine and AI tooling.
Silently delete a file without presenting errors if they occur. Helpful for cleanup scripts where the file may or may not exist, and you don’t want error messages cluttering the output.
$ErrorActionPreference = 'silentlycontinue'
Remove-Item "C:\test\test.txt"