How do I move a file to the Recycle Bin using PowerShell?
2017 answer: use the Recycle module Install-Module -Name Recycle Then run: Remove-ItemSafely file I like to make an alias called trash for this.
2017 answer: use the Recycle module Install-Module -Name Recycle Then run: Remove-ItemSafely file I like to make an alias called trash for this.
You can effectively “empty” the Recycle Bin from the command line by permanently deleting the Recycle Bin directory on the drive that contains the system files. (In most cases, this will be the C: drive, but you shouldn’t hardcode that value because it won’t always be true. Instead, use the %systemdrive% environment variable.) The reason … Read more
Use FileSystem.DeleteFile and specify the right RecycleOption. While this will work with UI Interactive Apps, it will not work with non UI interactive apps like a Windows Service app.