Powershell 删除日志文件不会';行不通

Powershell 删除日志文件不会';行不通,powershell,Powershell,我有一个PowerShell脚本,我计划使用它删除超过一定天数的日志文件 $path = "C:\users\example\desktop\test\*" Get-ChildItem -Path $path -Include *txt | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-30) } | Remove-Item 现在脚本在我创建的测试txt文件上运行良好,但在日志文件上不起作用。每个文件刚刚超过400MB,

我有一个PowerShell脚本,我计划使用它删除超过一定天数的日志文件

$path = "C:\users\example\desktop\test\*"
Get-ChildItem -Path $path -Include *txt | Where-Object {
    $_.LastWriteTime -lt (Get-Date).AddDays(-30)
} | Remove-Item

现在脚本在我创建的测试txt文件上运行良好,但在日志文件上不起作用。每个文件刚刚超过400MB,因此
Remove Item
可以处理的文件大小有限制吗?或者我遗漏了什么?

不要在路径中包含通配符

GCI C:\Users\Example\Desktop\Test -Include *txt |
  ? { $_.LastWriteTime -lt (Get-Date).AddDays(-30) } |
  Remove-Item -Force

-include*log、*txt
?尝试在
删除项
上添加
-Force
,看看这是否有区别。@4c74356b41可能是正确的,但要明确的是,哪些文件扩展名没有被删除<代码>*.log?@4c74356b51是正确的。包括*日志删除了较大的文件。谢谢你的帮助