Powershell - 如何检查具有所需创建时间的文件是否存在? [英] Powershell - How to check if file with desired creation time exists?
本文介绍了Powershell - 如何检查具有所需创建时间的文件是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用这个脚本
$date = Get-Date
Get-Childitem -name | where {$_.CreationTime -eq "$date"}
但它不起作用.我所需要的只是做一个布尔检查是否有在特定日期创建的文件.谢谢.
but it doesn't work. All I need is to do a boolean check if there is a file created in specific date. Thank you.
推荐答案
Get-Date
获取当前日期和时间.如果您将文件的创建日期与当前日期和时间进行比较,您将找不到任何文件(除非您在检索当前日期时刚刚创建了一个 ;) ).
Get-Date
gets the current date and time. If you compare a file's creation date with the current date and time you won't find any files (except you just have created one while retrieving the current date ;) ).
$today = (get-date).Date
Get-ChildItem | where { $_.CreationTime.Date -eq $today }
这篇关于Powershell - 如何检查具有所需创建时间的文件是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文