【问题标题】:Copy files where lastwritetime -ge 3/26/2010 9:00pm with Powershell使用 Powershell 将文件复制到 lastwritetime -ge 3/26/2010 9:00pm
【发布时间】:2010-04-13 21:58:42
【问题描述】:

我需要将一个目录中的文件复制到另一个目录,其中 lastwritetime 大于或等于 2010 年 3 月 26 日晚上 9:00。我正在使用:

Get-ChildItem C:\pstest\hlstore\folder1\data | where-object {$i.lastwritetime -ge “3/26/2010 9:00 PM”} | Copy-Item -destination c:\pstest\hlstore2\folder1\data

但是什么也没发生……

任何帮助将不胜感激。

谢谢!

情绪

【问题讨论】:

    标签: powershell-2.0 get-childitem


    【解决方案1】:

    试试这个:

    Get-ChildItem C:\pstest\hlstore\folder1\data | where-object {$_.lastwritetime -ge "3/26/2010 9:00 PM"} | Copy-Item -destination c:\pstest\hlstore2\folder1\data
    

    where-object 中“it”变量的名称是 $_,而不是 $i

    此外,如果您使用这些引号 “” 而不是 "",我认为它也会失败。

    【讨论】:

    • 完美!就是这样!非常感谢马蒂尼奥
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-01
    • 1970-01-01
    • 2015-09-20
    相关资源
    最近更新 更多