2017-10-04 48 views
0

當我運行下面的PowerShell的工作流程:UNC錯誤

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 
} 

我碰到下面的錯誤,但我仍然可以將R腳本的結果:

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" 

但是,當我運行命令Start-LocalRScript script1.R沒有錯誤。看起來工作流正試圖訪問RScript.exe網絡中的用戶的本地路徑,即使我指定了腳本Start-LocalRScript上的RScript.exe的位置。有人知道這裏發生了什麼嗎?

回答

0

而不是呼叫運營商(&)使用Start-Process-WorkingDirectory設置爲正確的工作目錄。