robocopy is giving error with compiled script

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: robocopy is giving error with compiled script

Post by DevinL »

I have a couple things from the team:

1) Attempt to run the exe outside of PowerShell, either run the exe normally from the desktop or try launching it from a normal cmd.exe console.
2) If it does error, then there might be an entry in the Windows Event Log that can shed some light on the crash. I recommend opening the log viewer and running the executable, then refreshing the log page to find it much easier.
DevinL
SAPIEN Technologies, Inc.
User avatar
ashishk
Posts: 19
Last visit: Mon Apr 10, 2017 12:08 am

Re: robocopy is giving error with compiled script

Post by ashishk »

Thanks DevinL

I tried with PowerShell command windows as well command windows infact run as Administrator.

I did not found anything in log viewer as well.

I will wait for your update.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: robocopy is giving error with compiled script

Post by DevinL »

[TOPIC MOVED TO WINDOWS POWERSHELL FORUM BY MODERATOR]
DevinL
SAPIEN Technologies, Inc.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: robocopy is giving error with compiled script

Post by DevinL »

The error is reported from the pipeline so it's not our packager that's causing this error exactly. That being said, I've moved this topic to the Windows PowerShell forum in case any community members may have some ideas.
DevinL
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: robocopy is giving error with compiled script

Post by jvierra »

RoboCopy can be sensitive to the threading model. Be sure you are using correct architecture 32/64.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: robocopy is giving error with compiled script

Post by jvierra »

I would also recommend against using RoboCopy to copy single files. Just use Copy-Item
User avatar
ashishk
Posts: 19
Last visit: Mon Apr 10, 2017 12:08 am

Re: robocopy is giving error with compiled script

Post by ashishk »

Hi jvierra

I shared only sample file to provide about the issue.

I also tested for copy directory and its subfolders using following robocopy syntex, but unfortunately getting same error.

Robocopy $sourceFolderPath $pathDir

Secondly I can use copy-item as well especially when you are using mulfiple folder and subfolders,and if path is too long, copy-item wont support.

Please advise.

Ashish
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: robocopy is giving error with compiled script

Post by jvierra »

RoboCopy requires a file template or lit of templates. You cannot skip this argument.

The minimum is"

robocopy <source folder> <detinationfolder> <filename template>
  1. robocopy -? |Out-Gridview
  2.  
  3.              Usage :: ROBOCOPY source destination [file [file]...] [options]
  4.  
  5.             source :: Source Directory (drive:\path or \\server\share\path).
  6.        destination :: Destination Dir  (drive:\path or \\server\share\path).
  7.               file :: File(s) to copy  (names/wildcards: default is "*.*").
paths cannot end with a '\' and file names must not contain a path. All arguments must be strings and not objects or arrays.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: robocopy is giving error with compiled script

Post by jvierra »

ashishk wrote:Hi

Here is the script

$logLocal = "c:\users\$Env:USERNAME\AppData\Local\MyLogs\"
$centralizedLocation = "c:\appLogs\"
$copyLog=$logLocal +$Env:USERNAME+"_"+ "AdminActivity" +"_"+$logDate +".txt"
$filename = Split-Path $copyLog -leaf

robocopy $logLocal $centralizedLocation $filename

Let me know if you need more information.
Your example breaks most of the rules.

The following would be what you seem to be looking for.
  1. $logLocal = "c:\users\$Env:USERNAME\AppData\Local\MyLogs"
  2. $centralizedLocation = 'c:\appLogs'
  3. $filename = "$Env:USERNAME_AdminActivity_$logDate.txt"
  4. # check target file
  5. $targetFilePath = join-Path $logLocal $filename
  6. if (Test-Path $targetFilePath) {
  7.     robocopy $logLocal $centralizedLocation $filename
  8. } else {
  9.     Write-Host 'File not found'
  10. }
User avatar
ashishk
Posts: 19
Last visit: Mon Apr 10, 2017 12:08 am

Re: robocopy is giving error with compiled script

Post by ashishk »

OK, I tested your code as well, but getting same error.

ERROR: Program 'Robocopy.exe' failed to run: The method or operation is not
ERROR: implemented.At line:12 char:1
ERROR: + robocopy $LogLocal $CentralizedLocation $Filename
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
ERROR: At line:12 char:1
ERROR: + robocopy $LogLocal $CentralizedLocation $Filename
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedEx
ERROR: ception
ERROR: + FullyQualifiedErrorId : NativeCommandFailed
ERROR:


Infact I tested I different machine as well, but getting same error.

Any other suggestion>
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked