[英]Powershell script to check for a file that was created on the date of today
我正在为我的公司编写脚本。 此脚本的目标之一是如果今天创建了文件,则检查目录。 然后它应该返回文件存在或文件不存在的消息,以防今天没有创建文件。 下面你可以看到我已经走了多远。 我也已经尝试过 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)};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.