Copy files where lastwritetime -ge 3/26/2010 21:00 with Powershell

I need to copy files in one directory to another directory where lastwritetime is greater than or equal to 3/26/2010 21:00. I use:

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

+4
source share
1 answer

Try the following:

 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 variable name "it" in the where-object is $_ , not $i .

Also, if you use these quotation marks "" instead of "" , I think it will also fail.

+5
source

Source: https://habr.com/ru/post/1306858/


All Articles