如何解决Powershell脚本来检查在今天的日期创建的文件
我正在为我的公司编写脚本。该脚本的目标之一是检入目录中是否已创建文件。然后,如果今天没有创建文件,则应返回消息文件存在或文件不存在的消息。在下面,您可以看到我走了多远。我也已经尝试过Test-Path命令,但没有成功。
$FOUND = $True
$dir = "directory path" #Cant put the real directory path in here out of security reasons
$latest = Get-ChildItem -Path $dir | Where-Object {$_.CreationTime -gt (Get-Date).Date}
if($Path -eq $FOUND) {
Write-Host 'File exists'
}
else {
Write-Host 'File does not exist'
}
我也尝试过if-else语句。
希望可以为您提供帮助 谢谢
解决方法
如何今天在Powershell中更新文件?
Get-ChildItem -Path C:\Users\Username\Desktop\Folder | where {([datetime]::now.Date -eq $_.lastwritetime.Date)};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。