Link to home
Start Free TrialLog in
Avatar of WeTi
WeTi

asked on

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.

Thanks.
Avatar of WeTi
WeTi

ASKER

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...

$source="C:\temp\source"
$dest="C:\temp\dest"

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

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

Open in new window

Avatar of Qlemo
There is a contradiction here - do you want to use robocopy or not within PowerShell? And if not, why? And if, why using PowerShell?
Avatar of WeTi

ASKER

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.
Avatar of WeTi

ASKER

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.
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

Avatar of WeTi

ASKER

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

thanks
What's wrong with my suggestion?
Avatar of WeTi

ASKER

Nothing wrong, its just in Orchestrator you need a variable of that process so it can pass through
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial