Delete Files to the Recycle Bin from PowerShell
Use Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile/DeleteDirectory with SendToRecycleBin for recoverable deletes in scripts.
01Command
$ Add-Type -AssemblyName Microsoft.VisualBasic
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile('C:\Temp\old.txt', 'OnlyErrorDialogs', 'SendToRecycleBin')02What it does
Remove-Item bypasses the Recycle Bin entirely — gone is gone. The .NET VisualBasic FileSystem class offers DeleteFile and DeleteDirectory with a RecycleOption of SendToRecycleBin, giving scripts the same safety net as dragging to the bin in Explorer. For folders use DeleteDirectory(path, 'OnlyErrorDialogs', 'SendToRecycleBin'); you can also swap the UI option to 'SendToRecycleBin' variants that don't prompt.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- FileSystem.DeleteFile MethodEvidence: The RecycleOption.SendToRecycleBin argument sends the deleted file to the Recycle Bin instead of permanently removing it.
Last verified: 2026-09-18 · Category: Files & Folders
06Related solutions
Diagnose NTFS file system errors and bad sectors on any volume — including the system drive while Windows is running — before committing to a repair.
Robocopy is Windows' built-in robust file copier: use /MIR to keep a destination folder as an exact one-way mirror of a source, resumable and restartable.
Search inside text files and logs with regex, returning file, line number and match.