Powershell copy files 90 days ago to another folder

Dear expert

I added a question yesterday about copying files from powershell to another folder... And oBdA recommended to run robocopy, now this is not possible to do anymore, it needs powershell script to process this.

Now i need a script that first check the files and folders and subfolder if its created from 90 days ago, if its created 90 days ago to currentdate, copy those to a folder.

Anyone have idea? I will try script this too myself tho... See how far I can go.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

WeTiAuthor Commented:
I kind find this code below
But I need powershell to check when robocopy is done... now this is around 200GB files and copy those files with powershell seems not that good...


$what = @("/COPYALL","/B","/SEC","/MIR")
$options = @("/R:0","/W:0","/NFL","/NDL")

$cmdArgs = @("$source","$dest",$what,$options)
robocopy @cmdArgs

Open in new window

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
There is a contradiction here - do you want to use robocopy or not within PowerShell? And if not, why? And if, why using PowerShell?
WeTiAuthor Commented:
Well I would like to use powershell due to the automatic processing reason, to understand the whole process is this:
We are using SCCM Orschestrator automatic schedule tools and SCCM is not working well with robocopy, what happen in the runbook of SCCM is that you processing a robocopy job and then it just passed it, due to running the robocopy command is fine, problem occure later that next step is to zip everything in that folder now... robocopy is still running in the background its not finished and SCCM is trying to zip the folder, this would not work...

For powershell is that we are not sure if it can handle 100gb files to copy... So I am doing testes for it right now.
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

WeTiAuthor Commented:
Here is idea, I want Powershell to check robocopy task in the background if it finds robocopy in running task, it will wait 10 second, and it will check again and again until robocopy task is gone from the task.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
RoboCopy is much better suited to handle large amounts of data than PowerShell, so I agree.
All you have to run in PS to wait for Robocopy to finish is:
while (get-process robocopy.exe*) { sleep 10 }
# and now proceed

Open in new window

WeTiAuthor Commented:
I want to declare a variable first and do a loop like:

$process = get-process robocopy.exe*

do ($process = true) {sleep 10} until ($process = false)

Somewhat like that but I know this need to modify. Please help me make this more right? Thanks

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
What's wrong with my suggestion?
WeTiAuthor Commented:
Nothing wrong, its just in Orchestrator you need a variable of that process so it can pass through
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Then you should use
while ($process = get-process robocopy.exe*) { sleep 10 }
# and now proceed

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.