[英]Delete files from Windows 2008 file explorer using PowerShell
I'd like to delete log files using a task scheduler from a 2008 Windows server that'll be run using a task scheduler.我想使用任务计划程序从 2008 Windows 服务器中删除日志文件,该服务器将使用任务计划程序运行。 I've created my own and used online scripts but nothing has worked.我创建了自己的并使用了在线脚本,但没有任何效果。 After running the the script manually on the server a prompt appears that halts this process (which seems to be the issue).在服务器上手动运行脚本后,会出现一个提示,停止此过程(这似乎是问题所在)。 Below is a script that I've run on my pc that worked and the OS is Windows 1903 and it worked.下面是我在我的电脑上运行的一个脚本,操作系统是 Windows 1903,它工作正常。 The only discrepancy that I could this of is that the PowerShell versions are different.我能做到的唯一差异是 PowerShell 版本不同。 Could someone provide advice as to why is doesn't delete files on a Windows 2008 OS?有人可以就为什么不删除 Windows 2008 操作系统上的文件提供建议吗?
Skeleton Script:骨架脚本:
Get-ChildItem –Path "C:\path\to\folder" -Recurse | Get-ChildItem –Path "C:\path\to\folder" -Recurse | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-60))} | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-60))} | Remove-Item除去项目
Aaron,亚伦,
Change remove-item to remove-item -Confirm:$false -force It will stop asking you to confirm the deleting of files.将 remove-item 更改为 remove-item -Confirm:$false -force 它将停止要求您确认删除文件。 – Aaron – 亚伦
This solved the issue.这解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.