4

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. 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

billinkc
  • 59,250
  • 9
  • 102
  • 159
Emo
  • 486
  • 4
  • 9
  • 19

1 Answers1

7

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.

R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510