robocopy is giving error with compiled script

Ask your Windows 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.
DevinL
Site Admin
Posts: 1098
Joined: Mon Aug 17, 2015 2:25 pm

Re: robocopy is giving error with compiled script

Post by DevinL » Fri Mar 31, 2017 9:29 am

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
Joined: Mon Feb 13, 2017 1:09 pm

Re: robocopy is giving error with compiled script

Post by ashishk » Fri Mar 31, 2017 11:30 am

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
Site Admin
Posts: 1098
Joined: Mon Aug 17, 2015 2:25 pm

Re: robocopy is giving error with compiled script

Post by DevinL » Fri Mar 31, 2017 1:24 pm

[TOPIC MOVED TO WINDOWS POWERSHELL FORUM BY MODERATOR]
DevinL
SAPIEN Technologies, Inc.

DevinL
Site Admin
Posts: 1098
Joined: Mon Aug 17, 2015 2:25 pm

Re: robocopy is giving error with compiled script

Post by DevinL » Fri Mar 31, 2017 1:25 pm

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: 14019
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: robocopy is giving error with compiled script

Post by jvierra » Fri Mar 31, 2017 3:05 pm

RoboCopy can be sensitive to the threading model. Be sure you are using correct architecture 32/64.

jvierra
Posts: 14019
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: robocopy is giving error with compiled script

Post by jvierra » Fri Mar 31, 2017 3:11 pm

I would also recommend against using RoboCopy to copy single files. Just use Copy-Item

User avatar
ashishk
Posts: 19
Joined: Mon Feb 13, 2017 1:09 pm

Re: robocopy is giving error with compiled script

Post by ashishk » Sat Apr 01, 2017 11:48 am

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: 14019
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: robocopy is giving error with compiled script

Post by jvierra » Sat Apr 01, 2017 12:27 pm

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.

jvierra
Posts: 14019
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: robocopy is giving error with compiled script

Post by jvierra » Sat Apr 01, 2017 12:35 pm

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. }

User avatar
ashishk
Posts: 19
Joined: Mon Feb 13, 2017 1:09 pm

Re: robocopy is giving error with compiled script

Post by ashishk » Sun Apr 02, 2017 8:11 pm

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>

Locked