简体   繁体   English

使用 PowerShell 从 Windows 2008 文件资源管理器中删除文件

[英]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.

相关问题 Powershell删除备份的文件/存档位/ Windows 2008 R2 - powershell delete backed up file / archive bit / windows 2008 R2 Windows 2008上使用Powershell的PackageAware打印驱动程序 - PackageAware Print Driver using Powershell on Windows 2008 如何使用Java从Windows文件资源管理器返回文件路径 - How to return the file path from the windows file explorer using Java 在Windows 7上:相同的路径,但Explorer和Java看到的文件不同于Powershell - On Windows 7: Same path but Explorer & Java see different files than Powershell 在 Windows 10 Build 20H2 使用 PowerShell 从任务栏取消固定 Inte.net Explorer - Unpin Internet Explorer from the Taskbar in Windows 10 Build 20H2 using PowerShell 从Windows 8应用程序在Windows资源管理器中打开文件? - Opening a file in Windows Explorer from a Windows 8 app? 使用Python COM在Windows资源管理器中选择文件? - Using Python COM to select files in windows explorer? 如何使用批处理文件在 Windows 10 中删除具有特定名称的文件? - How to delete files with specific names in windows 10 using batch file? Windows批处理命令用于从一个文件夹中删除文件 - Windows batch command to delete files from a folder except one file 如何在 Windows 中使用 CMD/PowerShell 通过 REGEX 匹配后删除多个文件? - How To Delete Multiple Files After Matching Through REGEX Using CMD/PowerShell In Windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM