Page 2 of 3

Re: robocopy is giving error with compiled script

Posted: Fri Mar 31, 2017 9:29 am
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.

Re: robocopy is giving error with compiled script

Posted: Fri Mar 31, 2017 11:30 am
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.

Re: robocopy is giving error with compiled script

Posted: Fri Mar 31, 2017 1:24 pm
by DevinL
[TOPIC MOVED TO WINDOWS POWERSHELL FORUM BY MODERATOR]

Re: robocopy is giving error with compiled script

Posted: Fri Mar 31, 2017 1:25 pm
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.

Re: robocopy is giving error with compiled script

Posted: Fri Mar 31, 2017 3:05 pm
by jvierra
RoboCopy can be sensitive to the threading model. Be sure you are using correct architecture 32/64.

Re: robocopy is giving error with compiled script

Posted: Fri Mar 31, 2017 3:11 pm
by jvierra
I would also recommend against using RoboCopy to copy single files. Just use Copy-Item

Re: robocopy is giving error with compiled script

Posted: Sat Apr 01, 2017 11:48 am
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

Re: robocopy is giving error with compiled script

Posted: Sat Apr 01, 2017 12:27 pm
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.  
  4.  
  5.              Usage :: ROBOCOPY source destination [file [file]...] [options]
  6.  
  7.  
  8.  
  9.             source :: Source Directory (drive:\path or \\server\share\path).
  10.  
  11.        destination :: Destination Dir  (drive:\path or \\server\share\path).
  12.  
  13.               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.

Re: robocopy is giving error with compiled script

Posted: Sat Apr 01, 2017 12:35 pm
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.  
  3. $centralizedLocation = 'c:\appLogs'
  4.  
  5. $filename = "$Env:USERNAME_AdminActivity_$logDate.txt"
  6.  
  7. # check target file
  8.  
  9. $targetFilePath = join-Path $logLocal $filename
  10.  
  11. if (Test-Path $targetFilePath) {
  12.  
  13.     robocopy $logLocal $centralizedLocation $filename
  14.  
  15. } else {
  16.  
  17.     Write-Host 'File not found'
  18.  
  19. }

Re: robocopy is giving error with compiled script

Posted: Sun Apr 02, 2017 8:11 pm
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>