Create a System.DateTime object using the get-date
cmdlet
$date = get-date "09.04.2014 8:00 AM"
And use it like this
Get-ChildItem C:\mypm.com\www\ddf*\ | where-object { $_.LastWriteTime -gt $date}
Pergunta
I have a huge filesystem to copy on the 12th of April. My approach is to copy all files today and on the 12th. I only copy the files which are modified later.
I only check on the folder level like this:
Get-ChildItem C:\mypm.com\www\ddf\*\ | where-object {
$_.LastWriteTime -gt (09.04.2014)
}
How can I add an exact time to the date? I know it is possible but I checked the output of select lastwritetime
and wrote it in the same structure, no success.
Solução
Create a System.DateTime object using the get-date
cmdlet
$date = get-date "09.04.2014 8:00 AM"
And use it like this
Get-ChildItem C:\mypm.com\www\ddf*\ | where-object { $_.LastWriteTime -gt $date}
Outras dicas
You can use a complete date/time in a string:
... | where { $_.LastWriteTime -gt '2014-04-09 22:41' }
Conversion rules in this case state that the string on the right side will be converted to a DateTime
, thus working as expected.