【发布时间】:2010-10-04 14:01:48
【问题描述】:
我要做的是创建一个 PowerShell 脚本,它获取目录中的文件夹列表,该列表由正则表达式过滤,筛选出具有 nnnnnnx31 或 nnnnnnddd 的文件夹名称,其中 n = 前 6 个字符的 alpha 字符和最后 3 个是静态字符串 x31 的任一数字。接下来,它会筛选文件是否存在 90 天,这些文件将被复制到不同的目录。
当我尝试运行时:
get-childitem | where {$_.name -match "^\d{6}([a-zA-Z]{3}|x31)$"} | where {$_.lastwritetime -lt (get-date.adddays(-90)}
我得到错误:
You must provide a value expression on the right-hand side of the -lt operator
At line: 1 char: 96
+ get-childitem | where {$_.name -match "^\d{6}([a-zA-Z]{3}|x31)$"} | where {$_.lastwritetime -lt <<<< get-date.adddays(-90)}
我也尝试了以下方法,但没有成功:
get-childitem | where {$_.name -match "^\d{6}([a-zA-Z]{3}|x31)$"} | where {$_.lastwritetime -lt (get-date | foreach-object {$_.adddays(-90)}) }
有什么想法吗?
【问题讨论】:
标签: powershell