尝试使用Powershell在另一台服务器上远程运行exe并失败

问题描述

我们在多台服务器上都有Alteryx,并希望能够通过命令行或Powershell远程运行作业,而不是通过Alteryx API。

多年以来,我一直在本地通过命令行和Powershell在本地运行alteryx流,但是现在,对于多台服务器,我们需要以这种方式执行某些流,但是需要从React Web应用程序触发。我们尝试了该API,并且可以正常工作,但是作业通常排队太长时间,并且我们需要近乎实时的响应,并且这些作业在几秒钟内即可运行。我们的解决方案是在Alteryx API外部触发,以便在资源过多的工作节点上立即执行。

我们的问题是,在测试可以在本地运行的脚本时,如果运行alteryxenginecmd.exe程序,该脚本可以运行其他所有命令。

如果我将start-process与passthru一起使用,它将生成一个进程,但是alteryx作业没有输出,也没有检测到错误。 如果我使用Call运算符,并且如果失败,则无法找到工作流程,因此alteryxenginecmd.exe正在启动,但没有读取或接收要作为参数运行的流的完整路径。但它在本地工作正常。 我已经使用凭据强制登录以清除任何凭据问题,而结果没有变化。

我知道Powershell有一些奇怪之处,如果脚本是从远程服务器运行的,也许必须对如何指定命令进行一些调整?

这是我要从远程服务器运行的脚本,在所示的4种情况中,它都能正常工作

    $rundate = (Get-Date -format 'u') -replace "-",""  -replace ":","" -replace " ","-"
    $pgm2Run = "\<somepath>\RunScriptRemote\RunRemoteTest2 - NoDB.yxmd"
    $Bat2Run = "\\<somepath>\RunScriptRemote\RunRemoteTestJob.bat"
    $JobLogFile = "\<somepath>\RunScriptRemote\LogsJob\JobTranscript $rundate.txt"
    $ScriptLogFile = "\<somepath>\RunScriptRemote\LogsScript\RunJobTranscript $rundate.txt"
    Start-Transcript  -Path $ScriptLogFile 
    echo "  "
    echo "$rundate Start --> "
    Echo "$rundate Before start-process"
    #1  start-process -filepath "AlteryxEngineCmd.exe" -ArgumentList `"$pgm2Run`" -RedirectStandardOutput $JobLogFile  -Wait -Passthru  
    #2  start-process -filepath $Bat2Run   -RedirectStandardOutput $JobLogFile  -Wait -Passthru 
    #3  & AlteryxEngineCmd.exe "$pgm2Run"
    AlteryxEngineCmd.exe "$pgm2Run"
    echo "$rundate After start-process"
    echo "$rundate End --> " 
    Stop-Transcript 

此命令在Server1上运行以在server2上执行上述脚本

    Invoke-Command -ComputerName server2 -FilePath "\\<somepath>\RunScriptRemote\RunAlteryxAndLogIt.ps1"

这是结果:

20200831-094309Z Before start-process
AlteryxEngineCmd.exe Version 2019.4.8.22007 © Alteryx,Inc. - All Rights Reserved.
Started running \\<somepath>\RunRemoteTest2 - NoDB.yxmd
Error - Alteryx Engine: Can't read the file "
Invoke-Command -ComputerName server2 -FilePath "\\<somepath>\RunScriptRemote\RunRemoteTest2 - NoDB.yxmd"
Finished in 0.020 seconds with 1 error
20200831-094309Z After start-process

我不确定这是Powershell的问题,很可能是Alteryx的问题,因为问题似乎是正确执行了一个exe。该脚本从远程服务器正确触发,我测试了其他命令,所有命令均正常工作,虽然在本地运行相同脚本时在本地运行正常,但似乎无法让执行此exe的程序在远程运行时正常工作。就像一个障碍赛,一个运行另一个脚本的脚本。

任何熟悉从另一台服务器远程运行exe的powershell专家吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)