none
Asynchronous Robocopy RRS feed

  • Question

  • We're in the process of moving user files from one storage location to another. To speed up copying when necessary, I've been opening new CMD windows, entering a subdirectory for a robocopy source\destination path, I'd like to automate this. I've got the basic script down but I want the foreach statement to not wait for a command to finish before starting the next. So for example, if there are four subdirectories in the path provided, i'd like to spawn four separate windows. Below is what I've got thus far:

    $dirs = Get-ChildItem C:\temp | Select -ExpandProperty Name
    foreach ($dir in $dirs) {
     Robocopy "C:\temp\$dir" "C:\temp2\$dir" /E /XO /COPYALL
    }

    • Moved by Bill_Stewart Monday, May 1, 2017 5:07 PM Abandoned
    Thursday, March 30, 2017 12:28 AM

All replies

  • help start-process -full

    OR

    help start-job -full


    \_(ツ)_/

    Thursday, March 30, 2017 2:53 AM
  • help start-process -full

    OR

    help start-job -full


    \_(ツ)_/

    Ive tried both of those, guessing with the wrong syntax.  Start-Job would create jobs that run in the background, I want foreground windows that I can monitor. Start-Process wouldn't continue the loop, it would wait for each one to finish.
    Thursday, March 30, 2017 4:49 AM
  • I think you need to read the whole help.

    Don't ne afraid of careful and critical reading,.  It is a critical requirement for all junior techs.  Once you learn how to read the help you can progress to more complex technical documents.  Soon you will be a real tech,  Enjoy.


    \_(ツ)_/

    Thursday, March 30, 2017 7:27 AM