Copy files where lastwritetime -ge 3/26/2010 9:00pm with Powershell
I need to copy files in one directory to another directory where the lastwritetime is greater than or equal to 3/26/2010 9:00pm. 开发者_如何学Go I'm using:
Get-ChildItem C:\pstest\hlstore\folder1\data | where-object {$i.lastwritetime -ge “3/26/2010 9:00 PM”} | Copy-Item -destination c:\pstest\hlstore2\folder1\data
But nothing happens...
Any help would be greatly appreciated.
Thanks!
Emo
Try this:
Get-ChildItem C:\pstest\hlstore\folder1\data | where-object {$_.lastwritetime -ge "3/26/2010 9:00 PM"} | Copy-Item -destination c:\pstest\hlstore2\folder1\data
The name of the "it" variable in where-object
is $_
, not $i
.
Also, if you're using these quotes “”
instead of ""
, I think it would also fail.
精彩评论