Delete Files to the Recycle Bin from PowerShell

Use Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile/DeleteDirectory with SendToRecycleBin for recoverable deletes in scripts.

WindowsdeleteFilespowershellMedium risk
Load the Microsoft.VisualBasic assembly and call [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile(path, 'OnlyErrorDialogs', 'SendToRecycleBin').

01Command

Command
$ 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

RiskMedium risk
!Warning: Items in the Recycle Bin can still be purged by Clear-RecycleBin or storage cleanup — this is a safety net, not a backup.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • FileSystem.DeleteFile Method
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: 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