Powershell script to parse Robocopy logs and return list of failed to copy files

3/17/2015 update:v1.1 - Added functionality to gather file and folder copy summaries and export to CSVThis script will parse one or more Robocopy log files, and return a list of files that failed to copy and the corresponding error code.To see inline help, type in:Powershell disp

4.3 Star
6,158 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question

  • Cant get the cmdlet to load
    2 Posts | Last post March 01, 2019
    • Sam,
      I cant get the cmdlet Get-FailedFiles imported into Pwrshell. I see in the Q and A where you say you need to load the Get-FailedFiles.ps1 first to import the function.The download is a .TXT .I did not see anything that says to rename to .PS1
      If i rename and run i dont get any errors but dont get any output either and when i check the Command Get-FailedFiles is not listed as being imported.
    • Hi,
      Try using the Import-Module "Path of .ps1 file".
      Then the Get-FailedFiles cmdlet will be available.
  • "The filename or extension is too long"
    3 Posts | Last post October 15, 2017
    • Hi, I'm using robocopy to copy files to SharePoint Online, however a lot of the path lengths exceed SharePoint's limits.
      The robocopy logs are filled with ERROR 206 (0x000000CE) "The filename or extension is too long" entries, however when I parse the log file with Get-FailedFiles, none of the errors are reported.
      Any ideas how I can get a summary of these paths?
    • Can you post a sample section that has these errors?
    • 2017/09/19 13:54:34 ERROR 206 (0x000000CE) Scanning Destination Directory Z:\Archive\CHG\Delivery\CHG SharePoint\Source\CHG Working Source\OSBIntranet\Enterprise Library\App Blocks\UnitTests\Security\Configuration\Design\
      The filename or extension is too long.
      2017/09/19 13:55:08 ERROR 206 (0x000000CE) Scanning Destination Directory Z:\Archive\CHG\Delivery\CHG SharePoint\Source\CHG Working Source\OSBIntranet\Enterprise Library\App Blocks\UnitTests\Security\Cryptography\Configuration\Manageability\
      The filename or extension is too long.
      2017/09/19 13:55:38 ERROR 206 (0x000000CE) Scanning Destination Directory Z:\Archive\CHG\Delivery\CHG SharePoint\Source\CHG Working Source\OSBIntranet\Enterprise Library\App Blocks\UnitTests\Validation\Configuration\Design\
      The filename or extension is too long.
  • Duration time > 24 hours
    1 Posts | Last post July 05, 2017
    • Sam,
      I have Robocopy copies that run over 24 hours.  When I run your great script against the logs, it will error out on the statement: 
      $Duration  = [TimeSpan]$_.Substring(12,10).Trim()
      The error will be similar to this:  Cannot convert value "51:28:54" to type "System.TimeSpan". Error: "The TimeSpan could not be parsed because at least one of the numeric comp range or contains too many digits."
      I also see the error codes > 2 digits being truncated as reported by tsull360 below.
      Thanks and let me know if there are any newer versions available.
  • Truncate Error Code to 2 Digits?
    1 Posts | Last post April 25, 2017
    • Hello,
      In my robocopy logs I'm seeing an error code of 1392, however your script seems to be trimming it to a 2 digit error code (13). I believe this may be happening on line 177?
      It's not the end of the world, but could be confusing.
  • script is not working for me
    2 Posts | Last post January 23, 2017
    • Hi Sam,
      When I run this script I am getting error that
      "Get-FailedFiles : The term 'Get-FailedFiles' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
      At line:1 char:1
      + Get-FailedFiles (Get-ChildItem -Path .\logs | where { $_.Name.StartsWith('Robo') ...
      + ~~~~~~~~~~~~~~~
          + CategoryInfo          : ObjectNotFound: (Get-FailedFiles:String) [], CommandNotFoundException
          + FullyQualifiedErrorId : CommandNotFoundException"
    • Hi Umesh,
      You need to run the Get-FailedFiles.ps1 script first to load the Get-FailedFiles function before you can use it.
      For more information see https://superwidgets.wordpress.com/2015/03/12/file-share-migration-phase-4-dealing-with-files-that-failed-to-copy/
  • Appending results to same file
    1 Posts | Last post January 18, 2017
    • Hi,
      If using the Get-ChildItem function, multiple files can be processed however it doesn't seem to append the results to the same *.CSV, it overwrites the results. 
      Any ideas on that?
      Thank you! 
      PS Great program!
  • Parse all logs in folder and export to network share
    1 Posts | Last post June 07, 2016
    • I am able to parse all the logs, but I am having trouble exporting to a network share. I can modify the original script and hard code $failedfiles and $copystats parameters, but is that the best way to do it?
      I want to parse all the logs into a folder, export the results to a CSV on the network.
      Thank you
  • Script output not saving in Variable
    2 Posts | Last post October 29, 2015
    • Hi Sam, I can't make the output of the scripts saves into a variable.
      These are the steps I did:
      1) I renamed the script to *.PSM1 and put it in: System32\WindowsPowerShell\v1.0\Modules\Get-FailedFiles
      2) run the command:
      get-FailedFiles (Get-ChildItem -Path D:\logs | where {$_.Name.startswith('daily')}).FullName
      **this command runs well**
      3) Then I tried to save it into a variable:
      FailedVar = get-FailedFiles (Get-ChildItem -Path D:\logs | where {$_.Name.startswith('daily')}).FullName
      **But I just see the output in the console and nothing is saved in the variable.
      I typed $FailedVar to see if some content were inside...but nothing.
      Do you know what might be happening?.
    • Output is displayed at the screen and saved to the log file. 
      help Get-FailedFiles -ShowWindow
      to see the built-in help
      Use the parameters -FailedFilesCSV -CopyStatsCSV -Sum to see additional output saved to CSV files