简体   繁体   English

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

[英]Using PS: How to force delete files without sending to Recycle Bin?

I'm using below script in the task scheduler to delete some files every day:我在任务调度程序中使用以下脚本每天删除一些文件:

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

It works.有用。 However, those files will be sent to Recycle Bin.但是,这些文件将被发送到回收站。 So we still need to empty the Recycle Bin once a while.所以我们仍然需要偶尔清空回收站。 Is there a way to delete files with sending to Recycle Bin using PS script (or maybe some setting in windows)?有没有办法通过使用 PS 脚本(或 Windows 中的某些设置)发送到回收站来删除文件?

Thanks谢谢

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM