【问题标题】:How do I write a powershell script that gets the file with the most recent last write time from a folder?如何编写一个powershell脚本,从文件夹中获取最近一次写入时间的文件?
【发布时间】:2010-04-14 11:13:10
【问题描述】:

主题行说明了一切。我也想使用管道来做到这一点。

我想我可以使用 Get-ChildItem、Measure-Object 和 Where-Object,但 Measure-Object 不喜欢日期。

我是否应该有一个脚本块循环遍历从 Get-ChildItem 返回的每个项目并进行比较以查看它是否是最新的?我认为应该有一个方便的 PS cmdlet。

【问题讨论】:

    标签: powershell


    【解决方案1】:
    Get-ChildItem | Sort LastWriteTime -Descending | Select -First 1
    

    【讨论】:

      猜你喜欢
      • 2019-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-24
      • 2020-02-06
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      相关资源
      最近更新 更多