4

我正在使用这个脚本

$date = Get-Date
Get-Childitem -name | where {$_.CreationTime -eq "$date"}

但它不起作用。我需要做的只是做一个布尔检查是否有在特定日期创建的文件。谢谢你。

4

2 回答 2

8

Get-Date获取当前日期和时间。如果您将文件的创建日期与当前日期时间进行比较,您将找不到任何文件(除非您在检索当前日期时刚刚创建了一个文件;))。

$today = (get-date).Date
Get-ChildItem | where { $_.CreationTime.Date -eq $today }
于 2012-05-03T14:36:50.743 回答
1
Get-ChildItem | where-object { $_.CreationTime.Date -match "2014" }

2014创世年在哪里。

于 2014-03-20T19:12:50.880 回答