Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top