使用PS:如何强制删除文件而不发送到回收站?

url*_*der 4 powershell

我在任务计划程序中使用以下脚本每天删除一些文件:

Get-ChildItem -Path "C:\Temp\*.txt" -force -ErrorAction SilentlyContinue | where {($_.LastwriteTime -lt  (Get-Date).AddDays(-1) ) -and (! $_.PSIsContainer)} | Remove-Item -Verbose -Force -ErrorAction SilentlyContinue
Run Code Online (Sandbox Code Playgroud)

有用。但是,这些文件将被发送到回收站。所以我们还是需要时不时的清空一下回收站。有没有办法使用 PS 脚本(或者 Windows 中的某些设置)发送到回收站来删除文件?

谢谢

Pri*_*vil 5

remove-item删除文件而不将其发送到回收站。