0

When I run the following powershell workflow :

Function Start-LocalRScript {
  Param([Parameter(ValueFromPipeline, Mandatory)]$Name)
  $ScriptPath = "C:\Exploration.RScripts"
  $RScriptExePath = "C:\Program Files\R\R-3.1.2\bin\Rscript.exe"
  $scriptPath = Join-Path -Path $ScriptPath -ChildPath $Name
  & $RScriptExePath $scriptPath
}

Workflow Get-RScriptWorkflow {
  Start-LocalRScript script1.R
}

I get the following error but I still get the result of the R script:

Rscript.exe : '\\srvuser01\profil\myUser\Documents' At Get-RScriptWorkflow:2 char:2
+ CategoryInfo          : NotSpecified ('\\srvuser01\profil\myUser\Documents':String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName        : [localhost] 
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.  
[1] "from script 1"

But when I run the command Start-LocalRScript script1.R there is no error. It seems that the workflow is trying to access the local path of my user that is in the network for the RScript.exe even though I specify where RScript.exe is on the script Start-LocalRScript. Does anyone know what is going on here?

1 Answer 1

0

instead of call operator (&) use Start-Process with -WorkingDirectory set to proper working directory.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.