header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Doing file backups with PS
Last Post 28 Oct 2007 04:01 AM by bsonposh. 1 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
blevblevUser is Offline
New Member
New Member
Posts:1

--
27 Oct 2007 09:06 PM  
So, I have a folder c:\xx that has two sub folders ..\test1 and ..\test2

I want to copy files newer than a certain date to folder c:\yy AND I want the script to automatically create the folder structure under c:\yy
 
I want to end up with c:\yy\test1 (and all the files from c:\xx\test1 in it) and c:\yy\test2 (and all the files from c:\xx\test2 in it.)

I've been searching the net without sucess and trial-and-erroring with no success.

Getting the list of files is fairly straight forward starting in the c:\xx folder - something like:

get-childitem -recurse | where {$_.LastWriteTime -ge "10/24/2007"}

This is where I get lost - if I try to pipe that into Copy-Item -destination "c:\yy" like this:

get-childitem -recurse | where {$_.LastWriteTime -ge "10/24/2007"} | Copy-Item -destination c:\yy 

I  get all the files (including the ones from c:\xx sub-folders) in c:\yy - and no sub folders.

I tried -recurse on the Copy-Item but that doesn't even make sense to me.

Can anyone help?
bsonposhUser is Offline
Basic Member
Basic Member
Posts:388

--
28 Oct 2007 04:01 AM  
You can use my script here http://bsonposh.com/modules/wordpress/?p=38

It will need a little mod to only copy by date. If you would like to try that I can help you along.

You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer