RoboPowerCopy – A PowerShell based RoboCopy clone

UPDATE 2021-07-23: Because of the Codeplex shutdown I have archived the project here:

Today I want to announce my latest development project.

RoboPowerCopy (v0.1.0.0)

It’s a PowerShell 2.0 based clone of Microsoft’s famous RoboCopy tool.

Get it on Codeplex:

RoboCopy tool is part of my daily work. At work and at home. – You all now it! I hope so Zwinkerndes Smiley

I spend the spare time of some weeks for this project and now it’s ready to be published as ALPHA version (v0.1.0.0). The development is still in progress!! – Hopefully there is somebody out there that will use it – beside me.

I’ve done this using the (also) famous PowerGUI (Community Edition) by Quest.

“But way” you may ask.

RoboCopy is an EXE file and it has closed source. We (the customers) are not able to change it’s behavior. E.g. I’m missing a “verify” feature for years. Some people say: “It’s a copy tool not a backup tool”. Okay. That’s right. But I want to be sure that the copied data is valid and identical to the source data.

Because of that I thought about the possibility to realize a RoboCopy clone with PowerShell. – So I did it now.

RoboPowerCopy is plain PowerShell. No assemblies or PowerShell extensions are needed. – It uses some inline C# code.

RoboPowerCopy should “understand” at least the commands (options) of RoboCopy. – Currently I’ve implemented a lot of RoboCopy’s abilities. Not all. But some new features on top, e.g. verify and “read-and-check-before-copy”. “Verify” uses .NET hashing algorithms to compare the written data to the source data. If the destination file already exists the “Read-and-check-before-copy” feature reads every portion of data from the destination file before it replaces the data portion on the destination file with the source file’s data. This should reduce the time that is needed to copy large files that have only a few binary changes.

As you may now .NET has no build in capabilities to handle with very long paths with more than 256 characters. I have developed a set of helper classes in C# that enable RoboPowerCopy to deal with very long paths. – This C# is included in the script an will be compiled at runtime into an assembly in memory.

Here are the abilities:

  • Long path support (!!)
  • Restartable mode using a temporary “copy header” at the end of the copied file.
  • Copy security: SACL, DACL, Owner
  • Copy file attributes and timestamps
  • Same option set as RoboCopy (not completely implemented)
  • Can be extended because it’s open source
  • Customizable
  • Pure PowerShell with some inline C# code
  • Compare file times as UTC
  • Modify it on any Windows Operation System >= Win XP / Windows 2003 Server with Microsofts PowerShell development tol Windows PowerShell Integrated Scripting Environment that is part of PowerShell.

These are the limitations:

  • No multithreading support
  • No “Job” files at the moment
  • Slower than RoboCopy (Because RoboPowerCopy is Powershell and/based on Managed Code but RoboCopy is native optimized code…)

The following options I have implemented (v0.0.1.0). There are some options that are not available in RoboCopy. These I’ve marked red.


since Version

/ACopy only files that have the Archive attribute set

/MRemoves Archive attribute of source file.

/A+:[HRAS]Add this file attributes to destination file

/A-:[HRAS]Remove this file attributes from destination file

/ECopy subfolder, including empty

/SCopy subfolders that are not empty. – “Not empty” means: at least one file is exists and is not excluded by any exclude option

/PURGERemove files on destination that does not exist on source

/MIRMirror the directory tree, like “/PURGE” combined with “/E”

/COPYALLCopy all file info: Timestamps, Attributes, Data, Owner, DACL, SACL

/COPY:[DATSOU]Copy selected file info: D=Data, A=Attributes, T=Timestamps, S=DACL, U=SACL, O=Owner

/DCOPY:[T]Copy selected directory info: T=Timestamps

/CREATEDoes only create the directory structure. Files will have zero size.

/SECCopy files with security. Like “/COPY:DATS”

/LEV:nCopy only n directory levels. 1=Copy only the given root directory.

/ISCopy even destination file seems to be the same as the source file.

/RCBWDuring overwrite this methos reads a file portion of data of the destination file and compares them with the source files portion of data before writing it. This my be useful while copying large files that have only few changes.

/VERIFYReread written data and compare them to the source data.

/SECFIXReplaces the security info of all destination files even if they are equal to the source.

/TIMFIXReplaces the timestamps of all destination files even if they are equal to the source.

/MAX:nMax file size to copy (in bytes)

/MIN:nMin file size to copy (in bytes)

/MAXAGEUsed to specify maximum file age based upon “LastWriteTime”. That will exclude files older than n days/date.
(If n < 1900 then n = no of days, else n = YYYYMMDD date).

/MINAGEUsed to specify minimum file age based upon “LastWriteTime”. That will exclude files newer than n days/date.
(If n < 1900 then n = no of days, else n = YYYYMMDD date).

/MAXLADUsed to specify maximum file age based upon “LastAccessTime”. That will exclude files unused since n days/date.
(If n < 1900 then n = no of days, else n = YYYYMMDD date).

/MINLADUsed to specify minimum file age based upon “LastAccessTime”. That will exclude files used since n days/date.
(If n < 1900 then n = no of days, else n = YYYYMMDD date).

/XD:<directory> [<directory> […]]Exclude this directories. Wildcards can be used for name matching.

/XF:<file> [<file> […]]Exclude this files. Wildcards can be used.

/XJExclude Junction Points, Symbolic Links (directories), Hard Links (files)

/XJDExclude Junction Points, Symbolic Links (directories)

/XJFExclude Hard Links (files)

/VDetailed output.

/VV[+][:<file>]Verbose output. If no file name is specified the messages will be written to the Powershell host using “write-verbose”

/CHUNK:nSize of the size of a portion of data during copy. In bytes. Default: 10mb.

/ZRestartable mode. A “copy header” will be used at the end of each file during the copy process. The header will be removed after copy is finished.

/BYTESShows file sizes in bytes

/R:nMaximum retry count if copy fails

/W:nWait duration before next retry. (In seconds)

/256Disable Long Path Support. This will use standard .NET classes (FileInfo, DirectoryInfo) instead of the special classes for file and directory names longer than 256 characters.

/NPNo progress – does not display “%”…

Using this option (except the red once) with RoboPowerCopy and RoboCopy should have the same result in both tools.

This features of RoboCopy does not work in RoboPowerCopy in v0.1.0.0:

  • Copy directory attributes
  • Set “Encrypted” attribute on destination files
  • Set “Compressed” attribute on destination files
  • …some more

Once more: It’s “ALPHA” in v0.1.0.0! – Therefore I want to ask for your help! – Please help to improve RoboPowerCopy. The project needs people how test and develop the script.

Please contact me at the projects Codeplex page if you would to spend your spare time for RoboPowerCopy.

13 thoughts on “RoboPowerCopy – A PowerShell based RoboCopy clone

  1. Pingback: Episode 151 – Jeremy Kelly Announces Script Explorer « PowerScripting Podcast

  2. Since we are rethinking and extending robocopy, can we also extend it to include the equivalent of unix rsync, allowing NFS to NTFS multi-threaded copy w/ source AUTH OpenLDAP and destination Active Directory. The reason, on NetApp filers, moving to from unix to Microsoft Server is not trivial and a tool like this would be useful at the enterprise level.

    • I’d definitely welcome an rsync like tool for powershell.

      Something that can check if a file is different (even just size and modified date) and send to a remote machine supporting PSSession or Credential

      I’ve been using copy-item -tosession but it’s horribly slow and attempts to copy every file even if it’s present on the remote server

  3. Hi,
    on Windows Server 2012 I get the error
    In D:\Temp\roboPowerCopy.ps1:3406 Zeichen:6
    + return $false
    + ~~~~~~~~~~~~~
    Das Steuerelement kann einen “finally”-Block nicht verlassen.
    In D:\Temp\roboPowerCopy.ps1:3703 Zeichen:8
    + return $false
    + ~~~~~~~~~~~~~
    Das Steuerelement kann einen “finally”-Block nicht verlassen.
    + CategoryInfo : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : ControlLeavingFinally

    MAny Greetings

    • I am also getting this error…..
      + return $false
      + ~~~~~~~~~~~~~
      Flow of control cannot leave a Finally block.
      + CategoryInfo: ParserError: (:) [], ParseException
      + FullyQualifiedErrorId : ControlLeavingFinally

  4. Teracopy and Gs Richcopy 360 replaces Robocopy very well and both have the ability to handle all issues that Robocopy can’t

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.