Zeno
Zeno

Reputation: 1829

Powershell, Get-ChildItem from today only

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

Answers (1)

Phillip Scott Givens
Phillip Scott Givens

Reputation: 5464

Why not just check the date?

$file_list = gci $foldern | where {([datetime]::now.Date -eq $_.lastwritetime.Date)};

Upvotes: 2

Related Questions