views:

175

answers:

1

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

A: 

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.

Martinho Fernandes
Perfect! That was it! Thanks so much Martinho
Emo

related questions