Powershell robocopy command

Colby Ralston 40 Reputation points
2023-06-14T12:54:23.09+00:00

Hello, I have been experimenting with Windows PowerShell recently and I have some questions about the robocopy command. Here is the code I used.

PowerShell Version:

Major Minor Build Revision


5 1 14393 5582

net use \SourceServer\D$ /user:Domain1\Admin1 *   
net use \DestinationServer\D$ /user:Domain2\Admin2 *  
robocopy \SourceServer\D$\FolderX%3 \DestinationServer\D$\FolderY /COPYALL /ZB /S /E /LOG:

I'm not putting my file paths for obvious reasons. However, this is what it was laid out like. This is my syntax, and I'm wondering if it has to do with where my /COPYALL /ZB /S /E commands are laid out. I am wondering if they have to be put in a certain order.

(IMPORTANT: I don't want to use /MIR because I don't want to delete the source shared folders files. This is being done from one shared folder to another. Both servers are on different domains that's why I used the Net use commands.)

The code copied the data over, but it only copied the folders and some of the data within the folders not all of it. I did testing on my newer laptop running Windows 11, and I also used the /DCOPY:DATE command. On this remote server that I used robocopy on from one server to another, it told me /DCOPY:DATE is not valid. I am assuming that is due to the version of PowerShell on that Windows 10 server. I found on my newer laptop /DCOPY:DATE copied everything, and /COPYALL did not. Is there any advice I could get on how to make this code properly work and copy absolutely everything?

Windows for business Windows Server User experience PowerShell
Microsoft System Center Other
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 36,291 Reputation points
    2023-06-14T13:58:59.93+00:00

    Robocopy.exe is a Windows executable and has nothing to do with Powershell. You can run robocopy in a good old command prompt.

    Run "robocopy /?" to display the help documentation. Refer to that for syntax questions.

    You have "/LOG:" but you did not specify a log file name. Remove that switch.

    Use the /l switch for testing. Robocopy will report on what it would do without copying any files.

    Use the /v switch to tell robocopy to produce verbose output. That may help you troubleshoot what files are being processed.

    /COPYALL should work fine. I don't normally use DCOPY, but /DCOPY:DATE should also be ok.

    
    /COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).
    /DCOPY:copyflag[s] :: what to COPY for directories (default is /DCOPY:DA).
                           (copyflags : D=Data, A=Attributes, T=Timestamps, E=EAs, X=Skip alt data streams).
    

    You probably don't need the /ZB switch.

    /MIR does not delete source folders/files, it deletes destination folders/files. I used /MIR to do data migrations that took a while to process. On the first run, I would run robocopy to copy the data from serverA to serverB. The issue was the users were still accessing (add/update/delete) the files on serverA. When the time came to cutover to the new server, we would modify the share permissions on serverA and remove update access to the users. Or just remove the share altogether. Then we would run a final robocopy with the /MIR switch to mirror the destination to the source. The first robocopy run copied the bulk of the data, the second run picked up all user changes that occurred during the time that first run was executing.

    Pick a small subfolder and run tests. Use /l and /v to analyze what is being copied. Pick a small subfolder and run tests. Use /l and /v to analyze what is being copied. As always, make sure that you have a good backup in case something bad happens.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.