I am running a Robocopy command and I am now getting a strange error where it once worked. I did look at several other StackExchange articles, but they do not deal with what I am dealing with.
- Talks about C# code
- Command for Robocopy to log created date
- Create File with current Date in Filename + Robocopy logging
- Robocopy: ERROR : Invalid Parameter #4
I created some code that adds a date to the end of the robocopy log.
$ReportDate = (Get-Date).tostring("dd-MM-yyyy-hh-mm-ss")
$RoboCopyLog = New-Item -itemType File -Path C:\Results -Name $("RoboCopyLog_" + $ReportDate + ".txt")
I have logs where this was working, but after some Windows updates and not touching it for a few weeks, I am now getting this error.
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Tuesday, March 21, 2017 7:24:56 AM
Source - C:\MyTests\
Dest - C:\NewTests\
Files :
Options : /S /E /DCOPY:DA /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
ERROR : Invalid Parameter #4 : "/L:C:\Results\RoboCopyLog_21-03-2017-07-24-56.t
xt"
Simple Usage :: ROBOCOPY source destination /MIR
source :: Source Directory (drive:\path or \\server\share\path).
destination :: Destination Dir (drive:\path or \\server\share\path).
/MIR :: Mirror a complete directory tree.
For more usage information run ROBOCOPY /?
**** /MIR can DELETE files as well as copy them !
The command I am using to create my robocopy job is as follows:
$RoboCopy2 = Start-Job {
$Results = "C:\Results"
$Source = "C:\MyTests"
$Destination = "C:\NewTests"
$ReportDate = (Get-Date).tostring("dd-MM-yyyy-hh-mm-ss")
$RoboCopyLog = New-Item -itemType File -Path C:\Results -Name $("RoboCopyLog_" + $ReportDate + ".txt")
Robocopy $Source $Destination /E /L:$RoboCopyLog
}
Wait-Job $RoboCopy2
Receive-Job $RoboCopy2