简体   繁体   中英

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)?

Thanks

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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