Question : Need help with a simple Powershell copy script

I am running this below script to incrementally copy files that have changed on a weekly basis.

The problem I am coming across is that all of the files being copied are being placed on the root of the DataNew directory, and are not getting placed in proper subfolders that exist in the Data folder, even though I am using the recurse tag. Is there something that I maybe need to do with paths?

Here is the script:

1:
2:
3:
4:
5:
6:
7:
foreach ($i in Get-ChildItem C:\Data -recurse)
{
    if ($i.LastWriteTime -lt ($(Get-Date).AddDays(-7)))
    {
        Copy-Item $i.FullName C:\DataNew
    }
}



Thanks

Parts of the script borrowed from Technet.

Answer : Need help with a simple Powershell copy script

Good consultant actually suppose to ask those question to figure out what you need.
First define in plain English for yourself what you need and, if this is existing application, what is our major  problem(s).

For better use of consultant time, if possible, try to split his visits. For example if you have DB performance/blocking problems you may need to get his advise on how to collect sample queries form trace, - this may take 1 hour, 1 day or 1 week or more depending on your application design and usage. Then you will implement their suggestions and again it may take time to see is if works or not.

if your intention is complete DB redesign - you need to prepare detailed description of your application, use cases, define what is UI for your database,  and list major problems with existing design

If your concerns is capacity/scalability - you need to define where you expect your growth and how DB structude will support it


 
Random Solutions  
 
programming4us programming4us