Reputation: 1829
What's the best way to grab files from today only in Powershell? I have this:
$file_list = gci $foldern | where {([datetime]::now - $_.lastwritetime).TotalHours -lt 24};
But it grabs files from the last 24 hours, and not quite "today".
Upvotes: 0
Views: 5419
Reputation: 5464
Why not just check the date?
$file_list = gci $foldern | where {([datetime]::now.Date -eq $_.lastwritetime.Date)};
Upvotes: 2